Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Code gone bad

Posted on 2007-03-22
5
Medium Priority
?
213 Views
Last Modified: 2008-03-06
Is there something wrong with this code because when I use it the page just keeps loading and loading and loading...  I have to close out the browser to do anything.

<?php
} elseif ($_GET['review'] == "review") {

$SQLstr = mysql_query("SELECT DISTINCT strCompanyname FROM tblReviews ORDER BY strCompanyName")
or die("SQL statement is not working");

$i = 0;
while ($i < 3) {
      $i = $i+1;
      if ($i == 1) {
            echo("<tr>");
      }
      echo("<td>");
?>
     <a href="/admin/edit_reviews.php?Company=<?= $strCompanyname ?>" >
       <?= $strCompanyname ?>
     </a>
<?php
      echo("</td>");
      if ($i == 3) {
             echo("</tr>");
            $i = 0;
      }
      }
}
?>
0
Comment
Question by:pingeyeg
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 1200 total points
ID: 18771446
you are looping endless around i = 0..1..2..3 .. 0..1...2..3 ... etc, as you do not "read" the query !!!

<?php
} elseif ($_GET['review'] == "review") {

$SQLstr = mysql_query("SELECT DISTINCT strCompanyname FROM tblReviews ORDER BY strCompanyName ")
or die("SQL statement is not working");

$i = 0;
while ($row = mysql_fetch_assoc($SQLstr))
{
      $i++;
      $strCompanyname = $row["strCompanyname"];

      if ($i == 1) {
            echo("<tr>");
      }
      echo("<td>");
?>
     <a href="/admin/edit_reviews.php?Company=<?= $strCompanyname ?>" >
       <?= $strCompanyname ?>
     </a>
<?php
      echo("</td>");
      if ($i == 3) {
             echo("</tr>");
            $i = 0;
      }
      }
}
?>
0
 
LVL 20

Assisted Solution

by:steelseth12
steelseth12 earned 200 total points
ID: 18771448
$i is never less than 3 thus your are stuck in an infinite loop
0
 
LVL 1

Author Comment

by:pingeyeg
ID: 18771472
angelIII, you sound angry??
0
 
LVL 11

Assisted Solution

by:elfe69
elfe69 earned 600 total points
ID: 18771485
$i can never be > 3 because when it reaches 3 you set it to 0 again in:

 if ($i == 3) {
             echo("</tr>");
            $i = 0;
      }

And your query result is never used...
0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 18771537
>angelIII, you sound angry??
nope. just put exclamation marks to show that that "detail" was important (should have jumped into your eyes :-) )
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Suggested Courses

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question