SirChick Posted October 16, 2007 Share Posted October 16, 2007 Hey, i made a sql to count the number of rows found but it says its not a valid supplied arguement.... Not sure how its typed correctly but this is how i done it: $CountRows = "SELECT * FROM messages WHERE Reciever='$Username'"; $numrows = mysql_num_rows($CountRows); If ($numrows == 3){ Die('3 is max'); } The Error: Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\xampp\htdocs\composeletterprocess.php on line 37 Quote Link to comment https://forums.phpfreaks.com/topic/73495-solved-count-num-rows/ Share on other sites More sharing options...
Orio Posted October 16, 2007 Share Posted October 16, 2007 You need to run the query first mysql_query($CountRows); Orio. Quote Link to comment https://forums.phpfreaks.com/topic/73495-solved-count-num-rows/#findComment-370751 Share on other sites More sharing options...
SirChick Posted October 16, 2007 Author Share Posted October 16, 2007 $CountRows = "SELECT * FROM messages WHERE Reciever='$Username'"; mysql_query($CountRows); $numrows = mysql_num_rows($CountRows); If ($numrows == 3){ Die('The letter box that belongs to this user is full, perhaps upgrade to better means of communication on the game?'); } Still getting the problem though =/ Quote Link to comment https://forums.phpfreaks.com/topic/73495-solved-count-num-rows/#findComment-370752 Share on other sites More sharing options...
darkfreaks Posted October 16, 2007 Share Posted October 16, 2007 are you connecting to your database using mysql_select_db? otherwise it wont connect. Quote Link to comment https://forums.phpfreaks.com/topic/73495-solved-count-num-rows/#findComment-370755 Share on other sites More sharing options...
mattal999 Posted October 16, 2007 Share Posted October 16, 2007 try: $CountRows = "SELECT * FROM messages WHERE Reciever='$Username'"; $numrows2 = mysql_query($CountRows); $numrows = mysql_num_rows($numrows2); If ($numrows == 3){ Die('The letter box that belongs to this user is full, perhaps upgrade to better means of communication on the game?'); } Quote Link to comment https://forums.phpfreaks.com/topic/73495-solved-count-num-rows/#findComment-370758 Share on other sites More sharing options...
envexlabs Posted October 16, 2007 Share Posted October 16, 2007 The post above has it right. you weren't putting the mysql_query into a variable. to make things easier try going like this: $myquery = mysql_query('SELECT * FROM `table`'); $matt = mysql_num_rows($myquery); Just alot simpler Quote Link to comment https://forums.phpfreaks.com/topic/73495-solved-count-num-rows/#findComment-370761 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.