Hi, i am making a search engine in php and i just get a warning that i cant understand: Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/eoopoedt/public_html/sok/search.php on line 27 See it your self: http://eoop.org/sok/
My code:
<?php
$button = $_GET['submit'];
$search = $_GET['search'];
if (!$button)
echo "søket samsvarer ikke med noen dokumenter. <br>";
else
{
if (strlen ($search) <=0)
echo " Søket samsvarer ikke med noen dokumenter. <br>";
else
{
echo "Søkeordet ditt: <b>$search</b> <hr size '1'>";
mysql_connect("localhost","eoopoedt","200152007w");
mysql_select_db("eoop");
$search_exploded = explode(" ",$search);
foreach($search_exploded as $search_each)
{
$x++;
if ($x = 1)
$construct .= "keywords LIKE '%search_each%'";
else
$construct .= "OR keywords LIKE '%search_each%'";
}
$construct = "SELECT * FROM søkemotor WHERE $construct";
$run = mysql_query($construct);
$num_rows = mysql_num_rows($run);
if ($num_rows==0)
echo "Ingen treff på søkeordet ditt.";
else
{
echo "$foundnum resultater på ditt søkeordt";
while ($runrows = mysql_fetch_assoc($run))
{
$title = $runrows['title'];
$desc = $runrows['description'];
$url = $runrows['url'];
echo"
<tb>$title </b><br>
$desc<br>
<a herf = '$url'>$url</a>";
}
}
}
}
?>