Jump to content

[SOLVED] No error but still get mysql_fetch_array(): supplied argument is not a valid MyS


Recommended Posts

HI. This one's got me stumped.

 

My query works, returns a record, does what it's supposed to do, but I still get mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/.sites/95/site29/web/data_recovery/admin/dre_fns.php on line 354.

 

I echo the query, run it via PhpMyadmin, and it returns a record and no error.

 

I use $result = mysql_query($query) or die(mysql_error()); and again, no error.

 

Here's the code:

 

*************************

 

$query = "SELECT *, CONCAT(tbl_customers.first_name, ' ', tbl_customers.last_name) as 'full_name' FROM tbl_cases LEFT JOIN tbl_customers ON tbl_customers.customer_id = tbl_cases.customer_id WHERE case_number='$case_number';";

echo"$query<br><br>";

$result = mysql_query($query) or die(mysql_error());

while ($row = mysql_fetch_array($result))

{

extract($row);

do some stuff;

}

 

**************************

 

It does the stuff but still gives the warning. Anybody have an ideas?

 

Thanks a million!

 

Bob

extract($row);
do some stuff; 

The part of your code that you omitted is overwriting $result. Either there is a column named result or you are setting $result to something else inside of the loop. Post your code to get the quickest solution.

You are correct! I was setting $result to something else inside the loop.

 

All other discussions I found regarding this error/warning concluded that 99.9% of the time the error was due to a bad query. I guess this is one of the other 0.01%.

 

Thank you!

Knowing that your code die()'ed when the query failed, eliminated a failed query as the reason. Leaving only the possibility that $result was being overwritten at some point after the query had been successfully executed.

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.