fri3ndly Posted August 6, 2008 Share Posted August 6, 2008 Hi all I recently encountered the following error: Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in \includes\DbConnector.php on line 52 The error cause is this mysql query when getting the number of rows (which works for other queries that do not use Match and against: $posts_query = "SELECT * FROM posts WHERE MATCH (post_title, post_description, post_location) AGAINST ('$get_search') ORDER BY post_title ASC" or die(mysql_error()); $posts_row_no = $conn->getNumRows($posts_query); When I run this through SQL (replacing the variable with desired text) in PHPMyAdmin it returns one row which is why I cannot understand the code not working. Any help please? Thanks Link to comment https://forums.phpfreaks.com/topic/118456-solved-match-against-error-mysql-says-its-fine/ Share on other sites More sharing options...
Xurion Posted August 6, 2008 Share Posted August 6, 2008 echo your sql in PHP to make sure you're supplying the values you assume are being queried. Link to comment https://forums.phpfreaks.com/topic/118456-solved-match-against-error-mysql-says-its-fine/#findComment-609742 Share on other sites More sharing options...
fri3ndly Posted August 6, 2008 Author Share Posted August 6, 2008 Hi Xurion I have indeed done that, and entered teh staement into PHPMyAdmin and it finds one row without a problem Is there anything else I can paste in here to help you out a bit? Link to comment https://forums.phpfreaks.com/topic/118456-solved-match-against-error-mysql-says-its-fine/#findComment-609745 Share on other sites More sharing options...
Xurion Posted August 6, 2008 Share Posted August 6, 2008 It doesn't make sense. The query should return the same result in either. Are you sure you're connecting to the right database in PHP? Link to comment https://forums.phpfreaks.com/topic/118456-solved-match-against-error-mysql-says-its-fine/#findComment-609747 Share on other sites More sharing options...
DarkWater Posted August 6, 2008 Share Posted August 6, 2008 You never actually execute the query, so therefore you're just passing the string into getNumRows rather than the result resource. Link to comment https://forums.phpfreaks.com/topic/118456-solved-match-against-error-mysql-says-its-fine/#findComment-609748 Share on other sites More sharing options...
fri3ndly Posted August 6, 2008 Author Share Posted August 6, 2008 Xurion: I know thats what is strange. It echoes out this: SELECT * FROM posts WHERE MATCH (post_title, post_description, post_location) AGAINST ('funky') ORDER BY post_title ASC DarkWakter Thanks for the reply. The query execution is done in the DbConnector file so that I can just use functions for callking things to make it easier Link to comment https://forums.phpfreaks.com/topic/118456-solved-match-against-error-mysql-says-its-fine/#findComment-609751 Share on other sites More sharing options...
fri3ndly Posted August 6, 2008 Author Share Posted August 6, 2008 DarkWater you were correct. I had not put the $conn->query("STRING"); in Thank you very much! Link to comment https://forums.phpfreaks.com/topic/118456-solved-match-against-error-mysql-says-its-fine/#findComment-609752 Share on other sites More sharing options...
DarkWater Posted August 6, 2008 Share Posted August 6, 2008 Yeah. =P No problem. Link to comment https://forums.phpfreaks.com/topic/118456-solved-match-against-error-mysql-says-its-fine/#findComment-609753 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.