RE: [PHP] what am I doing wrong?

From: Date: Fri, 02 May 2003 19:21:05 +0000
Subject: RE: [PHP] what am I doing wrong?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-146180@lists.php.net to get a copy of this message
$_POST['list_serv'] is not an array. Should it be? Are there form elements in the form that is posting to this script called 'list_serv[]' ? > -----Original Message----- > From: Amanda McComb [mailto:amccomb@indiana.edu] > Sent: Friday, May 02, 2003 12:17 PM > To: php-general@lists.php.net > Subject: [PHP] what am I doing wrong? > > > Ok, so I have been trying to create a dynamic database driven form. In > the form, there is a list of checkboxes that come from a table in the > database. I can create the list just fine, but when I want to use the > data in the checkboxes, I keep screwing up. There are a few things that > need to be done with the data, but right now, so I can figure out what the > heck I'm doing wrong, all I want to do is submit the form and display the > values. I keep getting this error: > > Warning: Invalid argument supplied for foreach() in > /usr/local/packages/apache-1.3.27/htdocs/amccomb/prodev/customer_form.php > on line 563 > > Why am I so confused about this? > > Anyway, here is a snippet of code that is giving me errors. (the form > itself is soooo long, I don't > want to post everything). > > Join these list servs: > <?$query = "SELECT * FROM list_serv_t WHERE retired_flag is NULL > OR > retired_flag = 0 ORDER BY list_serv_name"; > $search_results = mysql_query($query) or die("Select Failed!"); ?> > > <?while ($search_result = mysql_fetch_array($search_results)) {?> > <INPUT > TYPE="checkbox" > NAME="list_serv[<? echo > $search_result['list_serv_cd']; ?>]" > SIZE="20" > MAXLENGTH="50" > VALUE="1"><? echo > $search_result['list_serv_name'] ?> <BR> > <? > } > > foreach( $_POST['list_serv'] as $list_serv_cd => $quantity) { > $quantity *= 1; // make it numeric > if($quantity) { // if one exists > echo $list_serv_cd; > } > } > > ?> >

« previous php.general (#146180) next »