Solved

Code gone bad

Posted on 2007-03-22
5
196 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 300 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 50 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 150 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

Suggested Solutions

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…
I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

734 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