Hi there, I've been out of this for a "long" while and i'm running my way through the book "PHP and Myqsl web development"
Anyway, I am basically getting an error message and I cant seem to shed any light on it.
the error is
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in (((my folder)) on line 29
I'm basically just cutting and pasting, just to "play around"
anyway
heres the search page
<html>
<head>
<title>Book-O-Rama Catalog Search</title>
</head>
<body>
<h1>Book-O-Rama Catalog Search</h1>
<form action="results.php" method="post">
Choose Search Type:<br>
<select name="searchtype">
<option value="author">Author
<option value="title">Title
<option value="isbn">ISBN
</select>
<br>
Enter Search Term:<br>
<input name="searchterm" type=text>
<br>
<input type=submit value="Search">
</form>
</body>
</html>
and the results page
<html>
<head>
<title>Book-O-Rama Search Results</title>
</head>
<body>
<h1>Book-O-Rama Search Results</h1>
<?
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("localhost", "#####", "######");
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_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>";
}
?>
</body>
</html>
Any ideas or help would be appreciated
Thnakyou