nitromaster Posted October 11, 2008 Share Posted October 11, 2008 I get "PHP Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /folder/add.php on line 73 PHP Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/nitroapp/public_html/apps/pages/demo/add.php on line 83" And it doesn't seem to be inserting/selecting data from the db. Lines 69 to 73 mysql_connect($SQL_HOST,$SQL_USER,$SQL_PASS) or die(mysql_error()); @mysql_select_db($SQL_DB) or die( "Unable to select database"); $query="SELECT * FROM demo where id='" . $_GET["pid"] . "' AND profile_id='" . $profile_id . "'"; $result=mysql_query($query); if (mysql_num_rows($result)==0) Lines 81 to 83 $query="SELECT * FROM demo where profile_id='" . $profile_id . "'"; $result=mysql_query($query); if (mysql_num_rows($result) != 0) This code did seem to work earlier so I must have broken something somewhere while making further edits. It also seems to work on another app (on about facebook apps here) without this warning. Any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/128043-solved-php-warning-mysql_num_rows-supplied-argument-is-not-a-valid-mysql-result/ Share on other sites More sharing options...
AndyB Posted October 11, 2008 Share Posted October 11, 2008 Change $result=mysql_query($query); to $result=mysql_query($query) or die("Error: ". mysql_error(). " with query ". $query); and post the message you receive. Quote Link to comment https://forums.phpfreaks.com/topic/128043-solved-php-warning-mysql_num_rows-supplied-argument-is-not-a-valid-mysql-result/#findComment-663045 Share on other sites More sharing options...
nitromaster Posted October 11, 2008 Author Share Posted October 11, 2008 Error: 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 ''demo' where id='9110775435' AND profile_id='7603565565'' at line 1 with query SELECT * FROM 'demo' where id='9110775435' AND profile_id='7603565565' Quote Link to comment https://forums.phpfreaks.com/topic/128043-solved-php-warning-mysql_num_rows-supplied-argument-is-not-a-valid-mysql-result/#findComment-663056 Share on other sites More sharing options...
AndyB Posted October 12, 2008 Share Posted October 12, 2008 If I had to guess, I'd say that either one of both of those database fields isn't defined to allow numbers in the multi-billion range. I don't understand quite why you need record ids that high - most of us are happy to start at 1. Post your table definition. Quote Link to comment https://forums.phpfreaks.com/topic/128043-solved-php-warning-mysql_num_rows-supplied-argument-is-not-a-valid-mysql-result/#findComment-663065 Share on other sites More sharing options...
PFMaBiSmAd Posted October 12, 2008 Share Posted October 12, 2008 Based on the posts, the table name in the first post is not the actual name in the query and was altered for the post and/or the table name is correct, but has single-quotes around it and the syntax shown in the first post is not actually what is in the query. Quote Link to comment https://forums.phpfreaks.com/topic/128043-solved-php-warning-mysql_num_rows-supplied-argument-is-not-a-valid-mysql-result/#findComment-663074 Share on other sites More sharing options...
AndyB Posted October 12, 2008 Share Posted October 12, 2008 I'd guess it was meant to be `demo` - stupid backticks Quote Link to comment https://forums.phpfreaks.com/topic/128043-solved-php-warning-mysql_num_rows-supplied-argument-is-not-a-valid-mysql-result/#findComment-663077 Share on other sites More sharing options...
nitromaster Posted October 12, 2008 Author Share Posted October 12, 2008 Yep, was the usage of quotes instead of backticks. Works now Thanks all Quote Link to comment https://forums.phpfreaks.com/topic/128043-solved-php-warning-mysql_num_rows-supplied-argument-is-not-a-valid-mysql-result/#findComment-663078 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.