Hi everyone, Having a bit of a nightmare here, absolutely no idea why this isn't working and my eyes are going hazy from looking at it for so long. Any ideas? echo mysql_num_rows($done); //Just put in for debugging - works fine if(mysql_num_rows($list) == 0) //Nothing in shop { return 0; } elseif(mysql_num_rows($done) == 0) //No Previous attempts - all in { return mysql_fetch_array($list); } while($done = mysql_fetch_array($done)) { $local[] = $done['pref']; } PHP: It doesn't really matter what's actually going on in the code, I'm fine with the concept. $done is a MySql query which executes without error. mysql_num_rows($done) returns 1 both times, which is perfectly correct. However when it gets to mysql_fetch_array($done), it decides that $done isn't a valid result resource. How is that possible? I've tried putting the query directly into the fetch array, it doesn't help. I'd love an SQL wizard to come help me at this point, I'm on the point of assuming that its a PHP quirk created just to spite me! Cheers
Yes, that worked without a hitch +REP. I had previously tried unsetting then resetting, and I'm still not sure exactly why the original way didn't work. If anyone knows, I'd be interested. Thanks so much for the workaround though
You were reassigning $done.. $done isnt a query in your original post, its the query result... in the loop, you were saying, pull the first record from $done, and assign it to $done, so on the second iteration, $done would be a record, rather then a result set
Which of course explains why it returned the first result and only threw the error once. Thanks a lot