Hello, I am extremely new to MySQL and have never managed to get working smoothly with PHP before. I am trying really hard to understand how to work it, and am almost there.
I have a problem which I do not know how to resolve and was wondering if anybody could help me. I have no idea what is wrong with the code and why I am getting the error message; Warning: Supplied argument is not a valid MySQL result resource in C:\apache\htdocs\sams\chapter10\results.php on line 47 I am currently using a book to aid me with MySQL, and this is an example from the book. It does not seem to work and I have no idea what I may have done wrong to obtain this warning. I have changed my login and password to question marks. <? if (!$searchtype || !$searchterm) { echo "You have not entered search details. Please go back and try again."; exit; } $searchtype = addslashes($searchtype); $searchterm = addslashes($searchterm); @ $db = mysql_pconnect("mesh", "bookorama", "bookorama123"); if (!$db) { echo "Error: Could not connect to database. Please try again later."; exit; } mysql_select_db("booktest"); $query = "select * from booktest where ".$searchtype." like '%".$searchterm."%'"; $result = mysql_query($query); $num_results = mysql_num_rows($result); echo "<p>Number of books found: ".$num_results."</p>"; for ($i=0; $i <$num_results; $i++) { $row = mysql_fetch_array($result); echo "<p><strong>".($i+1).". Title: "; echo stripslashes($row["title"]); echo "</strong><br>Author: "; echo stripslashes($row["author"]); echo "<br>ISBN: "; echo stripslashes($row["isbn"]); echo "<br>Price: "; echo stripslashes($row["price"]); echo "</p>"; } ?> The problem seems to be around the lines of code; $result = mysql_query($query); $num_results = mysql_num_rows($result); Any assistance is appreciated. Yours, GF. _________________________________________________________________ Chat with friends online, try MSN Messenger: http://messenger.msn.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]