Reputation: 9
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", "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);
?>
Upvotes: 0
Views: 1994
Reputation: 360672
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 (
Upvotes: 4