From: [EMAIL PROTECTED] Operating system: Linux PHP version: 4.2.3 PHP Bug Type: MySQL related Bug description: mysql_num_rows() not valid
I have a very simple PHP script, that searches a small mysql database for a result. And the result that I keep receiving pertaining to the mysql_num_rows() function is listed below. Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /bookorama/results.php on line 29 Number of books found: Here is some of the PHP script. <? trim($searchterm); if(!$searchtype || !$searchterm) { echo "You have not entered search details. Please go back and try again."; exit; } $searchtype = addslashes($searchtype); $searchtype = addslashes($searchterm); @ $db = mysql_connect("localhost", "headdive_jazz", "jazz"); if(!$db) { echo "Error: Could not connect to database. Please try again later."; exit; } mysql_select_db("books"); $query = "select * from books where ".$searchtype." like '%".$searchterm."%'"; $result = mysql_query($query); $num_result = 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 htmlspecialchars(stripslashes($row["title"])); echo "</strong><br>Author: "; echo htmlspecialchars(stripslashes($row["author"])); echo "<br>ISBN: "; echo htmlspecialchars(stripslashes($row["isbn"])); echo "<br>Price: "; echo htmlspecialchars(stripslashes($row["price"])); echo "</p>"; } ?> -- Edit bug report at http://bugs.php.net/?id=21198&edit=1 -- Try a CVS snapshot: http://bugs.php.net/fix.php?id=21198&r=trysnapshot Fixed in CVS: http://bugs.php.net/fix.php?id=21198&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=21198&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=21198&r=needtrace Try newer version: http://bugs.php.net/fix.php?id=21198&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=21198&r=support Expected behavior: http://bugs.php.net/fix.php?id=21198&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=21198&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=21198&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=21198&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=21198&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=21198&r=dst IIS Stability: http://bugs.php.net/fix.php?id=21198&r=isapi