Sparrow Posted July 31, 2008 Share Posted July 31, 2008 I keep getting this error over and over no matter what I do: mysql_num_rows(): supplied argument is not a valid MySQL result resource. It say it has to do with line 296: Here is line 296 and the lines around it. $result = mysql_query('SELECT * FROM `users` ORDER BY `users`.`signup_date` DESC LIMIT 0, 10 '); $num = mysql_num_rows($result); $i = 0; ?> I already tried putting OR die(mysql_error()); after 0, 10 '). That takes away the error but then the code dosen't work. Link to comment https://forums.phpfreaks.com/topic/117622-solved-mysql_num_rows-supplied-argument-is-not-a-valid-mysql-result-resource-error/ Share on other sites More sharing options...
ainoy31 Posted July 31, 2008 Share Posted July 31, 2008 just try this: $result = mysql_query('SELECT * FROM users ORDER BY signup_date DESC LIMIT 0, 10 '); Link to comment https://forums.phpfreaks.com/topic/117622-solved-mysql_num_rows-supplied-argument-is-not-a-valid-mysql-result-resource-error/#findComment-604999 Share on other sites More sharing options...
Sparrow Posted July 31, 2008 Author Share Posted July 31, 2008 Nope that didn't work :'( Link to comment https://forums.phpfreaks.com/topic/117622-solved-mysql_num_rows-supplied-argument-is-not-a-valid-mysql-result-resource-error/#findComment-605005 Share on other sites More sharing options...
ainoy31 Posted July 31, 2008 Share Posted July 31, 2008 oh. take out the DESC Link to comment https://forums.phpfreaks.com/topic/117622-solved-mysql_num_rows-supplied-argument-is-not-a-valid-mysql-result-resource-error/#findComment-605008 Share on other sites More sharing options...
waynew Posted July 31, 2008 Share Posted July 31, 2008 $result = mysql_query('SELECT * FROM `users` ORDER BY `users`.`signup_date` DESC LIMIT 0, 10 ') or die(mysql_error()); Trouble shoot. Link to comment https://forums.phpfreaks.com/topic/117622-solved-mysql_num_rows-supplied-argument-is-not-a-valid-mysql-result-resource-error/#findComment-605009 Share on other sites More sharing options...
akitchin Posted July 31, 2008 Share Posted July 31, 2008 the issue is most likely the space between 0, and 10; it could also be the trailing space in the query. SQL can be somewhat finnicky. try this: $result = mysql_query('SELECT * FROM `users` ORDER BY `users`, `signup_date` DESC LIMIT 0,10') or die(mysql_error()); also, and this may sound silly but you never know, make sure you've got a connection to the DB open and a DB selected. Link to comment https://forums.phpfreaks.com/topic/117622-solved-mysql_num_rows-supplied-argument-is-not-a-valid-mysql-result-resource-error/#findComment-605013 Share on other sites More sharing options...
Sparrow Posted July 31, 2008 Author Share Posted July 31, 2008 the issue is most likely the space between 0, and 10; it could also be the trailing space in the query. SQL can be somewhat finnicky. try this: $result = mysql_query('SELECT * FROM `users` ORDER BY `users`, `signup_date` DESC LIMIT 0,10') or die(mysql_error()); also, and this may sound silly but you never know, make sure you've got a connection to the DB open and a DB selected. I tried this SQL qery but then it started reading users as a column so I changed it to: mysql_query('SELECT * FROM `users` ORDER BY `signup_date` DESC LIMIT 0,10') or die(mysql_error()); Than I get the error Unknown column 'signup_date' in 'order clause'. signup_date is a column though, so why isn't it working. And yes I am pretty sure there is a connection the the database base because at the very top of the coding I put include 'db.php'; . db.php has the datase connection information. I used this same file on my old website and it works. Link to comment https://forums.phpfreaks.com/topic/117622-solved-mysql_num_rows-supplied-argument-is-not-a-valid-mysql-result-resource-error/#findComment-605032 Share on other sites More sharing options...
akitchin Posted July 31, 2008 Share Posted July 31, 2008 if it's telling you the column doesn't exist, it's because it doesn't exist. could be that you've misspelled it, could be that the server this application is sitting on has a different db design, who knows? have a look to make sure. SQL doesn't lie, even though sometimes even the most minor detail makes it seem like it is. alternatively, you could try removing the backticks and see if that helps. it likely won't though. Link to comment https://forums.phpfreaks.com/topic/117622-solved-mysql_num_rows-supplied-argument-is-not-a-valid-mysql-result-resource-error/#findComment-605044 Share on other sites More sharing options...
Sparrow Posted August 1, 2008 Author Share Posted August 1, 2008 I just erased all the coding that has to do with that section of the website and I did it agian and now it works . Link to comment https://forums.phpfreaks.com/topic/117622-solved-mysql_num_rows-supplied-argument-is-not-a-valid-mysql-result-resource-error/#findComment-605143 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.