Server Error - HTTP 500 (INTERNAL SERVER ERROR) Only when visiting this one PHP page
I am a beginner at PHP, I have made a few pages which insert into my MySQL DB, as well as retrieve. This one page always gives me the 500 error, but my other PHP pages dont (Such as the INSERT record). Running PHP 5.2, apache 2.2
<?php
$con = mysql_connect("localhost", "XXXX", 开发者_StackOverflow社区"XXXX");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("equipment", $con);
$result = mysql_query("SELECT * FROM equipmentwanted");
while $row = mysql_fetch_array($result))
{
echo $row['fname'] . " " . $row['lname'];
echo "<br />";
}
mysql_close($con);
?>
Some things to look at:
1) Not checking for query failures:
$result = mysql_query("SELECT * FROM equipmentwanted") or die(mysql_error());
^^^^^^^^^^^^^^^^^^^^^^
mysql_select_db("equipment", $con) or die(mysql_error());
^^^^^^^^^^^^^^^^^^^^^^
2) Syntax error:
while $row = mysql_fetch_array($result))
^--- missing a (
精彩评论