No results

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
trythisone
Forum Newbie
Posts: 5
Joined: Thu Mar 10, 2011 10:32 am

No results

Post 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);
?>
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: No results

Post 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.
Post Reply