Tutorial :Code is displayed even with entries in the database



Question:

The following code continues to be displayed even if there are entries 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>";  }  


Solution:1

If the code you're having a problem with is the same as quoted in your previous question... then the problem is here:

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

You're missing a $ before numresults on the second line.


Solution:2

how do you get $numrows? It can be the mistake.

What I usually do is:

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


Solution:3

Try:

echo "'$numrows'";  

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


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »