RE: problem with foreach

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I am sure that I am late to the party, but am sure that double or single quotes at least are needed around the attribute values to make this work


Civil Rights


bastien





----------------------------------------> Date: Mon, 22 Oct 2007 12:20:55 -0500> From: awilliam@xxxxxxxxxxxxxxxx> CC: php-general@xxxxxxxxxxxxx> Subject: Re:  problem with foreach>>>> Robert Cummings wrote:>> On Mon, 2007-10-22 at 18:07 +0100, Stut wrote:>>>>> Adam Williams wrote:>>>>>>> I have an html page with checkboxes:>>>>>>>> >>>> Modern>>>> Mississippi>>>> Civil Rights>>>> MilitaryHistory>>>> >>>>>>>> and mailform2.php containing:>>>>>>>> echo "you selected: ";>>>> /* 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?>>>>>>> Turn notices on. You will then get lots of notices about the use of an>>> undefined constant "option".>>>>>> You should be using $_POST['option'] instead - notice the quotes.>>>>>> Your HTML should really have double quotes around the attributes but>>> that's beyond the scope of this list.>>>>>>> He's still going to get an invalid argument warning though since PHP>> will automatically convert the unquoted key to a string and then look up>> the value. The problem is that the value doesn't exist or is not an>> array as expected.>>>> Cheers,>> Rob.>>>> Yeah, thats the problem I'm having for some reason. When I do:>> print_r($_POST['option']);>> it prints nothing.>> --> PHP General Mailing List (http://www.php.net/)> To unsubscribe, visit: http://www.php.net/unsub.php>

_________________________________________________________________
Are you ready for Windows Live Messenger Beta 8.5 ? Get the latest for free today!
http://entertainment.sympatico.msn.ca/WindowsLiveMessenger
-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux