Code appears even with database records

The following code keeps showing even though there are records in my database and I don't understand why. Am I missing something? I'm not sure if this makes sense, but help would be great. :)

if($numrows==0)
{
echo"<h3>Results</h3>";
echo"<p>Sorry, your search: &quot;".$escaped."&quot; returned zero results</p>";
}

      

0


a source to share


3 answers


If the code you are having the problem with is the same as the one in the previous question ... then the problem is here:

$numresults=mysql_query($query);
$numrows=mysql_num_rows(numresults);

      



You are missing $ to multiple results on the second line.

+5


a source


How do you get $ numrows? This could be a mistake.

I usually do:



if($numrows > 0 ){

  // Code

}else{
  echo"<h3>Results</h3>";
  echo"<p>Sorry, your search: "".$escaped."" returned zero results</p>";
}

      

+2


a source


Try:

echo "'$numrows'";

      

Directly above the if statement. If the output is not '0' then the problem is how you are assigning from 0 to $ numrows.

+2


a source







All Articles