MikeDXUNL Posted April 28, 2008 Share Posted April 28, 2008 Hi, haven't posted on here in a while but hope some people can help. I have a function: function checkNewMSG($suser) { $joe = mysql_query("SELECT * FROM messages WHERE to_username = '".$suser."' AND read = 'n'"); $count = mysql_num_rows($joe); $_SESSION['newmsgs'] = $count; } it says there is an error on line 330. Line 330: $count = mysql_num_rows($joe); Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\wamp\www\vgant\incl\functions.php on line 330 think someone could help me? Thanks in advance. - Mike Quote Link to comment https://forums.phpfreaks.com/topic/103211-solved-mysql_num_rows-error/ Share on other sites More sharing options...
pocobueno1388 Posted April 28, 2008 Share Posted April 28, 2008 That means there is a problem with the query. Put a die to catch the error. $joe = mysql_query("SELECT * FROM messages WHERE to_username = '".$suser."' AND read = 'n'")or die(mysql_error()); Quote Link to comment https://forums.phpfreaks.com/topic/103211-solved-mysql_num_rows-error/#findComment-528659 Share on other sites More sharing options...
MikeDXUNL Posted April 28, 2008 Author Share Posted April 28, 2008 heh, it's been a while since I coded. forgot to do that but still haven't a clue to how to fix this. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'read = 'n'' at line 1 Quote Link to comment https://forums.phpfreaks.com/topic/103211-solved-mysql_num_rows-error/#findComment-528660 Share on other sites More sharing options...
ohdang888 Posted April 28, 2008 Share Posted April 28, 2008 $joe = mysql_query("SELECT * FROM messages WHERE to_username = '{$suser}' AND read = 'n' ")or die(mysql_error()); Quote Link to comment https://forums.phpfreaks.com/topic/103211-solved-mysql_num_rows-error/#findComment-528665 Share on other sites More sharing options...
MikeDXUNL Posted April 28, 2008 Author Share Posted April 28, 2008 that's still giving me the same error. edit: SOLVED $joe = mysql_query("SELECT * FROM `messages` WHERE `to_username` = '{$suser}' AND `read` = 'n' ")or die(mysql_error()); Quote Link to comment https://forums.phpfreaks.com/topic/103211-solved-mysql_num_rows-error/#findComment-528667 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.