0

Hi all,

I AM TRYING TO CREATE A SEARCH ENGINE USING PHP AND MYSQL.
I've been hitting the same problem over and over in my development. Sometimes when i do a MySQL query I keep getting the error
Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\searchengine\search.php on line 68

I don't understand why. What does this error mean, am I doing something wrong?

I'm using php 5.3, it's definitely not my mysql statement. I'm lost >.<

I even simplify my query code and still the same problem. The general code look something like this:

//echo outconstruct
  $constructx = "SELECT * FROM searchengine WHERE $construct";
  
  $construct = "SELECT * FROM searchengine WHERE $construct LIMIT $s,$e";
  $run = mysql_query($constructx);
  
  $foundnum = mysql_num_rows($run);


  $run_two = mysql_query("$construct");
  
  if ($foundnum==0)
   echo "No results found for <b>$search</b>";
  else
  {

Edited by Ezzaral: Added code tags. Please use them to format all code that you post.

2
Contributors
1
Reply
2
Views
7 Years
Discussion Span
Last Post by SikoSoft
0

I would have to disagree that it definitely is not a problem with the query - I actually think that is the likeliest cause. The reason I believe this is because I've seen this warning many times myself, and it's always been something wrong with the query itself. If the query breaks for some reason (maybe you refer to a field which doesn't exist for example), then what happens is instead of returning a resource, FALSE is returned.

What I would recommend is echoing the query exactly as it is prior to being passed to mysql_query() - then go into phpmyadmin and try to execute it. It will probably point out what is wrong with the query.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.