I am creating a PHP search function -
$result=mysql_query($query);
$numItems = mysql_num_rows($result); //Number of items that resulted from the query
if ($numItems == 0) {
$query = "select * FROM $table WHERE (name LIKE '%$termSafe%' OR tags LIKE '%$termSafe%' OR search_tags LIKE '%$termSafe%' OR ingredients_1 LIKE '%$termSafe%') AND active=1 $queryOptions ORDER BY name ASC";
$result=mysql_query($query);
$numItems = mysql_num_rows($result);
if ($numItems == 0) {
return('no results');
} else {
return $result;
}
} else {
return $result;
}
When I run this, I get the following error:
Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in
IF I pull out that line $numItems - it runs fine? What am I missing?