warning message
Posted: Mon Jan 03, 2011 1:02 pm
hello,
i am making a search engine but whenever i enter more then one characters in a search box it shows me this error below.
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in c:\wamp\www\major project\search.php on line 40
no result found
in the following code:
i am making a search engine but whenever i enter more then one characters in a search box it shows me this error below.
Code: Select all
no result found
in the following code:
Code: Select all
<?php
//get dat
$button= $_GET['submit'];
$search= $_GET['search'];
if (!$button)
echo "you didn't pressed the button";
else
{
if(strlen($search)<1)
echo "please enter the search term first";
else
{
echo "you searched for <b>$search</b><hr size='1'>";
//database connectivity
mysql_connect ("localhost","root","");
mysql_select_db ("music_park");
//expload our search term
$search_exploded = explode(" ", $search);
foreach ($search_exploded as $search_each)
{
//construct query
$x++;
if ($x=1)
$construct .= "keywords LIKE '%$search_each%'";
else
$construct .= "OR Keywords LIKE '%$search_each%'";
}
//echo out construct
$construct = "SELECT * from searchengine WHERE $construct";
$run= mysql_query($construct);
$foundnum= mysql_num_rows($run);
if ($foundnum==0)
echo "no result found";
else
{
echo "$foundnum results found<p>";
}
}
}
?>