Mystery foreach error
| From: | Angela Barone | Date: | Tue, 12 Mar 2013 19:45:03 +0000 |
| Subject: | Mystery foreach error | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-320496@lists.php.net to get a copy of this message | ||
I've been getting the following error for awhile now, but I can't figure out why
it's happening:
Invalid argument supplied for foreach() in ... sample.php on line 377
Here's that portion of code:
include("states_zipcodes.php");
// Check if Zip Code matches from states_zipcodes
$zip_short = substr($zip, 0, 3);
foreach ($states[$state] as &$zip_prefix) { // <-- line 377
if ($zip_prefix == $zip_short) {
break;
} else {
$match = 'no';
}
}
It doesn't happen all the time, so I'm thinking that some spambot is populating the HTML
form with something the script doesn't like(?). However, I tested that myself by entering
text, or by entering just 2 digits, but there was no error. FYI, I do have code in the script that
catches faulty input and warns people in their browser to go back and re-enter the correct data, so
I'm at a loss as to why this is happening.
How can I see what's triggering this to happen? I have the following line in my php.ini:
error_reporting = E_ALL & E_STRICT & E_NOTICE & E_DEPRECATED
Thank you,
Angela