Jump to content

"Not A Valid MySQL Result Resource"


jonw118

Recommended Posts

I am getting an error:

 

"Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/***/public_html/projects/***/admin/inc/admin_info_class.php on line 180"

 

...that line's code is:

$row=mysql_fetch_array($rs);

 

It works fine on one of my other servers.

 

Any thoughts would be greatly appreciated!

Link to comment
https://forums.phpfreaks.com/topic/133442-not-a-valid-mysql-result-resource/
Share on other sites

In your code that says something like

$rs = mysql_query($something)

add or die(mysql_error());

 

$rs = mysql_query($something) or die(mysql_error());

That should tell you why the query isn't getting processed correctly.

 

This error usually points to the query not being successful.

When I do that or die to get the exact error I get:

 

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 '' at line 1

 

Line 1 is: <?php

 

 

-----------------------------------------

 

 

The full query is:

 

function allowed_user_category($mID){

$rs=mysql_query("select mem_ID,cat_ID FROM tbl_member WHERE mem_ID=$mID");

$row=mysql_fetch_array($rs) or die(mysql_error());

return $row["cat_ID"];

}

 

I'm thinking mID is empty - if it was numeric, he would get an empty result, but right now he is getting a syntax result. And since the location he is being told to check is near '', it means that it is at the end of the query. Therefore, the last part of the query must be the problem, and probably looks like this:

 

Where mem_id=

 

Since there is no value after the equals sign, it's a throwing back an error.

Archived

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

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