NEED SOME HELP PEOPS
Posted: Mon Mar 17, 2003 8:28 am
Hello, i have created a db, and loaded a set of values into it via a text file! However the problem occurs when i try to extract data from the db via a keyword search from a html form. The result shud give a list of values that match the search key that is entered!
The error that i get is this:
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /stud/ug/vxp00u/cgi-bin/viral/searchpage3result.cgi on line 33!
I would really appreciate it if some1 could point out where im goin wrong PLZ!
cheers VIRAL 
The error that i get is this:
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /stud/ug/vxp00u/cgi-bin/viral/searchpage3result.cgi on line 33!
I would really appreciate it if some1 could point out where im goin wrong PLZ!
Code: Select all
<html>
<head><title>TERM SEARCH RESULTS</title></head>
<body>
<h1>SEARCH RESULTS</h1>
<?php
trim($searchterm);
if (!$searchtype || !$searchterm)
{
echo "you have not entered search details, plz go bak and try again";
exit;
}
$searchtype = addslashes($searchtype);
$searchterm = addslashes($searchterm);
@ $db = mysql_connect("mysql.cs.nott.ac.uk", "username", "password");
if (!$db)
{
echo "error: could not connect to the database. please try again later.";
exit;
}
mysql_select_db("testtable");
$query = "SELECT * FROM testtable WHERE '.$searchtype.' LIKE '%".$searchterm."%'";
$result = mysql_query($query);
$num_results=mysql_num_rows($result);
echo "<p>Number of terms found: ".$num_results."</p>";
for ($i=0; $i < $num_results; $i++)
{
$row = mysql_fetch_array($result);
echo "<p><strong>".($i+1).".letter:";
echo htmlspecialchars( stripslashes($rowї"letter"]));
echo "</strong><br>term: ";
echo htmlspecialchars( stripslashes($rowї"term"]));
echo "</strong><br>meaning: ";
echo htmlspecialchars( stripslashes($rowї"meaning"]));
echo "</p>";
}
?>
</body>
</html>