Re: problem with foreach

From: Date: Mon, 22 Oct 2007 17:03:27 +0000
Subject: Re: problem with foreach
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-263507@lists.php.net to get a copy of this message
On Oct 22, 2007, at 1:01 PM, Adam Williams wrote:
I have an html page with checkboxes: <form action=mailform2.php method=POST> <input type=checkbox name=option[] value="Modern Mississippi">Modern Mississippi<br> <input type=checkbox name=option[] value="Civil Rights">Civil Rights<br> <input type=checkbox name=option[] value="Military History">MilitaryHistory<br> <input type=submit name=submit value=Submit> and mailform2.php containing: echo "you selected: <br>"; /* line 81 */ foreach ($_POST[option] as $a)
       {
       echo "$a";
       }
but I'm getting the error: you selected: *Warning*: Invalid argument supplied for foreach() in */var/www/sites/mdah-test/museum/mmhsurvey/mailform2.php* on line *81* I googled some checkbox/foreach pages on google, but I don't see where I'm going wrong. I'm running php 5.2.5 on Apache 2.2.4 on Fedora Linux. Any help?
Not sure if this would help or not but when ever I've done anything with $_POST variables or other array variables I have to specify it like $_POST['option'] notice the ' in around the word 'option' Hope it helps! -- Jason Pruim Raoset Inc. Technology Manager MQC Specialist 3251 132nd ave Holland, MI, 49424 www.raoset.com japruim@raoset.com

« previous php.general (#263507) next »