Jump to content

Archived

This topic is now archived and is closed to further replies.

nitromaster

[SOLVED] "PHP Warning: mysql_num_rows(): supplied argument is not a valid MySQL result:

Recommended Posts

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?

Share this post


Link to post
Share on other sites

Change

$result=mysql_query($query);

 

to

$result=mysql_query($query) or die("Error: ". mysql_error(). " with query ". $query);

 

and post the message you receive.

Share this post


Link to post
Share on other sites

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'

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

I'd guess it was meant to be `demo` - stupid backticks  :o

Share this post


Link to post
Share on other sites

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.