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!
Trying to view a guestbook but i keep getting this error which i am struggling to overcome hope you can help. The error is
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\Program Files\Apache Group\Apache2\htdocs\shopbots\view_guest.php on line 13
<?
//Display the top of the page for the guestbook
echo " <center><h1> Guestbook </h1></center><br>";
echo ' <a href="sign_guestbook.php"> Click here to leave us a message</a><br><br>';
echo " <b>comments from visitors </b><hr>";
//make the query
$query = "SELECT (username,email,comments) FROM users guestbook ORDER_BY user_id";
$result = @mysql_query ($query); //Run the query.
//Fetch and print all the records.
while ($row = mysql_fetch_array($result))
{
echo "<b>username:</b> $row[0]<br>email: </b>$row[1]<br>
<b>Comments:</b> $row[2]";
}
mysql_close(); // close the database connection
?>
ERROR, ERROR!You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'email,comments) FROM guestbook ORDER_BY user_id' at line 1
$query = "SELECT username, email, comments FROM guestbook ORDER_BY user_id";
This is the error
ERROR, ERROR!You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'user_id' at line 1