Jump to content

[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?

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'

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.

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.