Am 12.03.13 20:45, schrieb Angela Barone:
>       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

what is in $states?
Looks like $states[$state] is not an array.

And don't use & reference operator in foreach loop, there can be strange
side effects if you don't act carefully with it.

>     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


-- 
Marco Behnke
Dipl. Informatiker (FH), SAE Audio Engineer Diploma
Zend Certified Engineer PHP 5.3

Tel.: 0174 / 9722336
e-Mail: ma...@behnke.biz

Softwaretechnik Behnke
Heinrich-Heine-Str. 7D
21218 Seevetal

http://www.behnke.biz


Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to