Jump to content

what does this error message mean?


barrowvian

Recommended Posts

This is part of my code for a simple search function. It works for my test site on wampserver;

						//sql fulltext statement against words/phrase user enters
					$sql = "SELECT *, MATCH(company_name, search_data) AGAINST('%$_GET[searchterms]%') AS score FROM
					adverts WHERE MATCH(company_name, search_data) AGAINST('%$_GET[searchterms]%') LIMIT 0, 500";
									   
					$result = mysql_query($sql);

					//display an error if the query returns no results
					if (mysql_num_rows($result) < 1 && strlen($searchTerms) > 3 && strlen($searchTerms) < 50) {
         					echo "<font color=\"red\">No results found for <strong>{$searchTerms}</strong></font>.";
						$flag = "NOTOK";
      					}

 

However, when I host it live and try to use it I get this error message;

 

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/overone1/public_html/search.php on line 70

 

Line 70 is if (mysql_num_rows($result) < 1 && strlen($searchTerms) > 3 && strlen($searchTerms) < 50) {

 

Please could someone explain what I have done wrong here and what the best way to fix it is?

 

Thank you

 

Link to comment
https://forums.phpfreaks.com/topic/203982-what-does-this-error-message-mean/
Share on other sites

That error will occur when you have a syntax error in the mysql query, do this:

<?php
$sql = "SELECT *, MATCH(company_name, search_data) AGAINST('%$_GET[searchterms]%') AS score FROM
adverts WHERE MATCH(company_name, search_data) AGAINST('%$_GET[searchterms]%') LIMIT 0, 500";
$result = mysql_query($sql) or die("Problem with the query: $sql<br>" . mysql_error());
?>

 

and see what is displayed. The error should  point you in the right direction.

 

Ken

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.