mysql_fetch_array


#1

i have a testing server that this code works on. once i upload to my server i receive this error: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource
the code for this is

[php]
$qry=mysql_query(“select image,image_type from fampics where md5(image_id)=’$_GET[imgid]’”);

while($img=mysql_fetch_array($qry)){
[/php]
any ideas?

Admin Edit: Added [PHP] Tags for readability. Please refer to http://phphelp.com/guidelines.php for posting guidelines.


#2

are the login credentials, database name, db version, etc… the same on BOTH servers?

Can you run the query manually on the production server and get the results desired?

I also note that it’s not good to embed the super global inside the quoted string.

Consider doing it this way:

[php]
$qry=mysql_query(“select image,image_type from fampics where md5(image_id)=’”.$_GET[imgid]."’");

while($img=mysql_fetch_array($qry)){
[/php]

And to the NEXT level, you SHOULD (single) quote the index in the array. Not doing so may or may not work, but either way, it leaves a lot up to interpretation by php. Although I cannot tell you why, someone (I believe BANE) had made mention some time ago that this can create a performance issue as well.

So revise it to this:
[php]
$qry=mysql_query(“select image,image_type from fampics where md5(image_id)=’”.$_GET[‘imgid’]."’");

while($img=mysql_fetch_array($qry)){
[/php]


#3

i didnt have the correct credentials for the table. thanks for your help