chamster Posted May 6, 2009 Share Posted May 6, 2009 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 Link to comment https://forums.phpfreaks.com/topic/157047-solved-no-error-but-still-get-mysql_fetch_array-supplied-argument-is-not-a-valid-mys/ Share on other sites More sharing options...
PFMaBiSmAd Posted May 6, 2009 Share Posted May 6, 2009 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. Link to comment https://forums.phpfreaks.com/topic/157047-solved-no-error-but-still-get-mysql_fetch_array-supplied-argument-is-not-a-valid-mys/#findComment-827276 Share on other sites More sharing options...
chamster Posted May 6, 2009 Author Share Posted May 6, 2009 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! Link to comment https://forums.phpfreaks.com/topic/157047-solved-no-error-but-still-get-mysql_fetch_array-supplied-argument-is-not-a-valid-mys/#findComment-827691 Share on other sites More sharing options...
PFMaBiSmAd Posted May 6, 2009 Share Posted May 6, 2009 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. Link to comment https://forums.phpfreaks.com/topic/157047-solved-no-error-but-still-get-mysql_fetch_array-supplied-argument-is-not-a-valid-mys/#findComment-827706 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.