[thelist] RE: Arrays and Multiple Select?

McAtee, Malcolm MMcAtee at philamuseum.org
Wed Oct 10 13:42:56 CDT 2001


This gives me the following error message:  

"Variable passed to each() is not an array or object in
/export/web/company/philamuseum/public_html/information/development/thankyou
.php3 on line 23"

I find this encouraging actually. Any idea how to correct this?
Thanks Malcolm

========================================================================
<?php
print "Date:$Date<br>\n";
print "Company:$Company<br>\n";
print "Contact:$Contact<br>\n";
print "Address:$Address<br>\n";
print "Telephone:$Telephone<br>\n";
print "FAX:$FAX<br>\n";
print "eMail:$eMail<br>\n";

while(list($key, $value) = each($Type_Of_Event)) {   =====line 23is here!
       echo "$key = $value<br>";
       }

print "Desired Location:$Desired_Location<br>\n";
print "Special Needs:$Special_Needs<br>\n";
 ?>
========================================================================

//---------------//
Malcolm J. Mcatee
Web Designer
Philadelphia Museum of Art
215-684-7748
mmcatee at philamuseum.org
//---------------//

-----Original Message-----
From: Les Lytollis [mailto:les.lytollis at morse.com]
Sent: Wednesday, October 10, 2001 8:04 AM
To: 'thelist at lists.evolt.org'
Subject: RE: [thelist] RE: Arrays and Multiple Select?


foreach is PHP4 construct, try

while(list($key, $value) = each($Type_Of_Event)) {
  echo "$key = $value<br>";
}

Lez

> -----Original Message-----
> From: McAtee, Malcolm [mailto:MMcAtee at philamuseum.org]
> Sent: 10 October 2001 13:56
> To: thelist at lists.evolt.org
> Subject: RE: [thelist] RE: Arrays and Multiple Select?
> 
> 
> Thanks for the help!
> would you implement like this?
>  
> 
> action.php
> ===============================================
> <!-- results and confirmation --->
> You Have Entered the Following Information:<br>
> 
> <?php
> print "Date:$Date<br>\n";
> print "Company:$Company<br>\n";
> print "Contact:$Contact<br>\n";
> print "Address:$Address<br>\n";
> print "Telephone:$Telephone<br>\n";
> print "FAX:$FAX<br>\n";
> print "eMail:$eMail<br>\n";
> 
>     for($i=0;$i<count($Type_of_Event);++$i){
> 	print $Type_of_Event[$i];
> 	print "\n";
> };
> print "Desired Location:$Array[Desired_Location]<br>\n";
> print "Special Needs:$Special_Needs<br>\n";
>  ?>
> 
> <!-- e-mail --->
> <?php
>  mail
> ("mmcatee at philamuseum.org", "Facilities Inquiry", 
> "Date:$Date
>  Company:$Company
>  Contact:$Contact
>  Address:$Address
>  Telephone:$Telephone
>  FAX:$FAX
>  eMail:$eMail
>  Date of Event:$Date_of_Event
> 
> 
>   for($i=0;$i<count($Type_of_Event);++$i){
> 	print $Type_of_Event[$i];
> 	print "\n";
> };
> 
> 
>  Number of Attendees:$Number_of_Attendees
>  Desired Location:$Array[Desired_Location]
>  Special Needs:$Special_Needs
> ","FROM:Inquiry_Form")
> ?>
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> //---------------//
> Malcolm J. Mcatee
> Web Designer
> Philadelphia Museum of Art
> 215-684-7748
> mmcatee at philamuseum.org
> //---------------//
> 
> -----Original Message-----
> From: Joe Crawford [mailto:jcrawford at avencom.com]
> Sent: Tuesday, October 09, 2001 1:48 PM
> To: thelist at lists.evolt.org
> Subject: Re: [thelist] RE: Arrays and Multiple Select?
> 
> 
> "McAtee, Malcolm" wrote:
> > Sorry for posting this again, but any help would be appreciated.
> 
> Sure thing ...
> 
> > I still seem unable to pass these form.values in the 
> multiple select.
> 
> They're getting passed ... don't worry, you're just not reading them,
> looks like --
> 
> > i am not a php programmer but these seems conceptually sound to me.
> > Am I making a syntax error? do I need PHP4?(I am on 3) do I 
> need to rename
> > my file extensions to .php3?
> 
> Consult your sysadmin for that informaton - simple test is to make a
> simple helloworld.php and a helloworld.php3 file and upload with:
> 
> <?php echo "hello world"; ?>
> 
> And see what you get in each case.
> 
> Now, on to your code:
> > form.php
> >        <select name="Type_of_Event[]" size="3" multiple>
> <many snips>
> > 
> > print "Type_of_Event:<br>\n";
> > foreach($Type_of_Event as $event)
> > {
> >         print "$event<br>\n";
> > }
> 
> I'm not sure about that foreach syntax. I would use a for 
> loop like so:
> 
> for($i=0;$i<count($Type_of_Event);++$i){
> 	print $Type_of_Event[$i];
> 	print "\n";
> };
> 
> See also:
> http://www.php.net/manual/en/function.count.php
> http://www.php.net/manual/en/ref.array.php
> http://www.php.net/manual/en/control-structures.foreach.php
> 
> Hope that helps -- I made a test page - but only internally 
> -- check the
> code at the end of this note and save as foo.php
> 
> 	- Joe <http://artlung.com/>
> -- 
> ...................  Joe Crawford \\ Web Design & Development
> .....  mailto:jcrawford at avencom.com \\ http://www.avencom.com
> .... San Diego \\ CA \\ USA \\ AVENCOM: Set Your Sites Higher
> 
> <!-- code begins here, save as foo.php -->
> <pre>
> <form action="foo.php" method="get">
> ====================================================================
>    <select name="Type_of_Event[]" size="3" multiple>
>     <option value="Dinner">Dinner</option>
>     <option value="Lunch">Lunch</option>
>     <option value="Breakfast">Breakfast</option>
>     <option value="Cocktail Reception">Cocktail Reception</option>
>     <option value="Meeting">Meeting</option>
>     <option value="Other">Other</option>
>    </select>
>    <input type="submit">
> ====================================================================
> </form>
> <b>Type_of_Event:</b>
> <?
> /* php actually begins here */
> for($i=0;$i<count($Type_of_Event);++$i){
> 	print $Type_of_Event[$i];
> 	print "\n";
> };
> ?>
> </pre>
> <!-- code ends here, save as foo.php -->
> 
> ---------------------------------------
> For unsubscribe and other options, including
> the Tip Harvester and archive of TheList go to:
> http://lists.evolt.org Workers of the Web, evolt ! 
> 
> ---------------------------------------
> For unsubscribe and other options, including
> the Tip Harvester and archive of TheList go to:
> http://lists.evolt.org Workers of the Web, evolt ! 
> 

---------------------------------------
For unsubscribe and other options, including
the Tip Harvester and archive of TheList go to:
http://lists.evolt.org Workers of the Web, evolt ! 




More information about the thelist mailing list