Page 1 of 1

No results

Posted: Sun Mar 10, 2013 6:48 pm
by trythisone
I could use some advice so that I can retain the few hairs I have left.

I am getting absolutely nothing to display except the empty html table in the below code. I have executed the same query in phpmyadmin and gotten results, so I don't know what the difference is. Any suggestions on how I can troubleshoot it?

Code: Select all

<?php
// Create connection
$con = mysql_connect("localhost","user","passwd");

// Check connection
if (!$con)
  {
  echo "Failed to connect to MySQL: " . mysql_error();
  }
  
mysql_select_db("database", $con);

$sqlstr = "SELECT `title`,`description`,`location` FROM `recordings` LIMIT 0, 30";
$result = mysql_query($sqlstr) or die($sqlstr."<br/><br/>".mysql_error());
  
echo "<table border='1'>
<tr>
<th>Title</th>
<th>Description</th>
<th>Listen</th>
</tr>";

 while($row = mysql_fetch_array($result));
  {
  echo "<tr>";
  echo "<td>" . $row['title'] . "</td>";
  echo "<td>" . $row['description'] . "</td>";
  echo "<td>" . $row['location'] . "</td>";
  echo "</tr>";
  }



mysql_close($con);
?>

Re: No results

Posted: Sun Mar 10, 2013 7:59 pm
by requinix
You've got a trailing semicolon on the while statement. Means that empty statement is the body of the while loop and the { }s you have after are just a regular block of code... except $row is empty so you won't see anything.