i have users search through a database using a form. no one field is required, but any can be used.
i am trying to kick the results to a the num_rows() array and then echo to determine whether the script is getting anything back from database. i get the folllowing error:
mysql_num_rows(): supplied argument is not a valid MySQL result resource
here is the code:
$query = "select * from products where ";
$parameterStr = "";
if ($productname != "")
{
$parameterStr="productname LIKE '%$productname%' ";
}
if ($sku != "")
{
if ($parameterStr == "")
{
$parameterStr = "sku == $sku";
}
else
{
$parameterStr = $parameterStr." AND sku == $sku ";
}
}
if ($catID !="")
{
if ($parameterStr == "")
{
$parameterStr = "catID == $catID";
}
else
{
$parameterStr = $parameterStr." AND catID == $catID ";
}
}
if ($vendorID != "")
{
if ($parameterStr=="")
{
$parameterStr="vendorID == $vendorID ";
}
else
{
$parameterStr=$parameterStr." AND vendorID == $vendorID ";
}
}
$query = $query.$parameterStr;
$myquery = mysql_query($query);
$num_results = mysql_num_rows($myquery);
echo $num_results;
thanks for the input