barrowvian Posted June 5, 2010 Share Posted June 5, 2010 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 Quote Link to comment https://forums.phpfreaks.com/topic/203982-what-does-this-error-message-mean/ Share on other sites More sharing options...
dezkit Posted June 5, 2010 Share Posted June 5, 2010 that means you're query is incorrect Quote Link to comment https://forums.phpfreaks.com/topic/203982-what-does-this-error-message-mean/#findComment-1068355 Share on other sites More sharing options...
kenrbnsn Posted June 5, 2010 Share Posted June 5, 2010 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 Quote Link to comment https://forums.phpfreaks.com/topic/203982-what-does-this-error-message-mean/#findComment-1068358 Share on other sites More sharing options...
barrowvian Posted June 5, 2010 Author Share Posted June 5, 2010 haha very help mr state the obvious dezkit thank you though kenrbnsn that really helped. I hadnt changed my db to fulltext index. It works now though thanks again Quote Link to comment https://forums.phpfreaks.com/topic/203982-what-does-this-error-message-mean/#findComment-1068371 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.