Hi,
I am trying to add site search on my site
after creating database and connecting it I find this error
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource
can anybody help
thx in advance
Rgds
MM
Hi,
I am trying to add site search on my site
after creating database and connecting it I find this error
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource
can anybody help
thx in advance
Rgds
MM
It basically means the result variable you have in mysql_num_rows(); isn’t valid. This usually means your query hasn’t went through properly.
Hi,
Thanks for the prompt help as i am a designer I have taken code from net can you guide what shall I do to correct this code.
[php]
Search Engine - Searchforeach ($terms as $each){
$i++;
if($i == 1)
$query .= "keywords LIKE '%$each%' ";
else
$query .= "OR keywords LIKE '%$each%' ";
}
echo $query;
//connect
mysql_connect("localhost", "nicainst_gss2011", "2011gss");
mysql_select_db("nicainst_gss_db");
$query = mysql_query($query);
$numrows = mysql_num_rows($query);
if($numrows > 0){
while($row = mysql_fetch_assoc($query)){
$id = $row['id'];
$title = $row['title'];
$description = $row['description'];
$keywords = $row['keywords'];
$link = $row['link'];
echo "<h2><a href='$link'>$title</a></h2>
$description<br /> <br />";
}
}
else
echo "No results found for \"<b>$k</b>\"";
//disconnect
mysql_close();
?>
[/php]Are you certain that the example worked before it was posted and the database is setup correctly (the tables have been made and also had data put in them).
EDIT: Can you also echo out $query just before:
[php]$query = mysql_query($query);[/php]
E.g:
[php]echo $query;
$query = mysql_query($query);[/php]