I find this error strange in the while() loop (line 47). There is no reported connection (to mysql server) error. I can do the query manually in phpmyadmin. I can only guess this error is not accurate–triggered by something other than the arguments ($status_success, MYSQL_ASSOC)… Any guesses what’s happening. I’m stumped…
??
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /var/www/php/pl-bulk-cron-scriptie-swift.php on line 47
$email_event_status = "SELECT
email_status,
id,
is_update
FROM
event_email";
$status_success = mysql_query($email_event_status, $connectID);
if(!($status_success)){
exit('MYSQL ERROR - Unable to select content from database');
} // LINE 46
while($event_record = mysql_fetch_array($status_success, MYSQL_ASSOC)){
...some stuff to do on each row here...
}
I did more “homework” (yuck…this is not for “school” BTW). I found several sources suggesting the most common problem:
the query returns false.
Here is the select statement run at the command prompt:
Another point was to be sure to capture a MYSQL error if it occurs. To make the code simpler, I used the standard die() with the query, and used mysql_fetch_assoc():
$email_event_status = "SELECT
email_status,
id,
is_update
FROM
event_email";
$status_success = mysql_query($email_event_status, $connectID) or die ("MYSQL_ERROR_99 - Unable to select from database".error_get_last().mysql_error($connectID));
while($event_record = mysql_fetch_assoc($status_success)){
It looks like your trying to do a databse query again and using the result for the while loop. PHP says it doesn’t like the result given for mysql_fetch_array params.
…hahaa. Really its just stupid. Its a long while() and one of the references is an old field name. In my searches, there was no note that an incorrect array reference in the while() would trigger the supplied argument error. The supplied argument was not the passed var, rather a call in the array to a field that did not exist in the result set.
Again. Thanks for the help and putting up with the silliness of the post.
Chris
spence_n,
Thanks for the effort to try to clear this confusion.
Before I give the solution (I figured it out) let me say I thought about this before I posted. I started to create an array, and figured with the addition of mysql, it would be unlikely to recreate the same conditions in a simpler script. I continued to hammer at the problem. Then I out it away. After a reinvigorating bicycle ride, another approach suddenly came to my imagination. This distance allowed me to notice the answer…
The var $email_event_status is not itself a query, but a string of the MYSQL statement.
In case you’re curious, I’m just trying on this style of writing the query. Its just some script’n schenanigans along with moving the error off the end of the query and into an if statement.