i followed a video tutorial to make a guestbook using php but when i fininshed typing the file and executed it. it showed me an error that says "Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\wamp\www\myguestbook.php on line 38" and line 38 has the following " for ($i = 0; $i < mysql_num_rows($result); $i++)" and here is the script : [code] <?php require ($_SERVER["DOCUMENT_ROOT"]."/config/db_connect.php"); $connection = @mysql_connect ($db_host, $db_user, $db_password) or die ("error connecting"); mysql_select_db($db_name, $connection); $name = $_POST["txt_name"]; $len= strlen($name); //Only write to database if there's a name if ($len >0) { $email = $_POST["txt_email"]; $comment =$_POST["txt_comment"]; $date = time (); $query = "INSERT INTO guestbook (autoID, name, email, comment, date_auto) VALUES (NULL, '$name','$email','$comment','$date')"; mysql_query($query, $connection) or die (mysql_error ()); } ?> <html> <head> <title>Guestbook</title> <body> <center> <form action="<?php echo $_SERVER[PHP_SELF]; ?>" method="post"> <font face="arial" size="1"> Name: <input type="text" name="txt_name"> Email:<input type="text" name="txt_email"><br><br> Comment:<br> <textarea style="width: 75%" rows="10" name="txt_comment"></textarea> <center><input type="submit" value="submit"</font></center> </form> <table bgcolor="#AAAAAA" border="0" width="75%" cellspacing="1" cellpading="2" <?php $query="SELECT * FROM questbook ORDER BY date_auto"; $result = mysql_query($query, $connection); for ($i = 0; $i < mysql_num_rows($result); $i++) { $name = mysql_result($result, $i, "name"); $email = mysql_result($result, $i, "email"); $email= strlen($email); $comment = mysql_result($result,$i, "comment"); $date = mysql_result($result,$i, "date_auto"); $show_date ("H:i:s m/d/Y" , $date); echo ' <tr> <td width="50%" bgcolor="#EEEEEE"> <font face="arial" size="2">'; if ($email_len > 0) { echo '<b>Name:</b> <a href="mailto:'.$email.'>"'.$name.'</a>'; } else { echo '<b>Name:</b> '.$name; } echo ' <br> <b>Comment:</b> '.$comment.' </font> <td> <td width="1%" valign="top" nowrap bgcolor="#EEEEEE"> <b>Date: </b> '.$show_date.' </font> </td> </tr> '; } ?> </table> </center> </body> </html> [/code]