0

I am trying to query a database through PHP and have followed a tutorial, but I am getting an unusual error with how my echo statements are being displayed on the web page.

The section of code that seems to be broken is this:

$rowNum=mysql_num_rows($query);
echo "<p>There are ".$rowNum." people matching your results</p>";
echo "<table><tr><th>Name</th><th>Age</th><th>Gender</th></tr>";

while($row = mysql_fetch_array($query, MYSQL_ASSOC)) {
    echo "<tr><td>".$row['name']."</td>".
         "<td>".$row['age']."</td>".
         "<td>".$row['gender']."</td></tr>";
    }
echo "</table>";

and instead of displaying the data in a nice table, it outputs a very messed up page. I have never seen an error like this before in php, and I was wondering if any of you guys know a fix for it. Thanks!

Please note: I am using a web server. I am not just making a .php page and opening it in chrome.

Ethan Zimbelman
  • 371
  • 2
  • 6

0 Answers0