Re: Need help accessing the values of an array in a form ...

From: Date: Thu, 23 May 2002 00:07:22 +0000
Subject: Re: Need help accessing the values of an array in a form ...
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-98840@lists.php.net to get a copy of this message
"John Kelly" <johnkelly@hotmail.com> wrote in message news:20020522235855.17940.qmail@pb1.pair.com... > Hi, I have a form using the post method that outputs a dynamic number of > fields each time with the same name but different values - this is required. > For example ... > > filename[] > filename[] > filename[] > filename[] > > On the next page I try to access the array using ... > > for($i=0; $i<count($filename); $i++) { > $value = $filename[$i]; > do something with $value ... > } > > but $filename[0], $filename[1], $filename[2], etc each contain one letter > from the word "Array" if there were say five items in the array!? What am I > doing wrong and/or how do I get the actual values? > > Update ... when I remove the following code which comes before the code above it works. Anyone know why it does not work when the following code is in there and/or how I can modify the following code so I can keep it in and still get the array to work. I have register globals off and want to protect the data going into a database which is what I thought the purpose of the following code was for. foreach($HTTP_POST_VARS as $k=>$v){ if (get_magic_quotes_gpc()){ $HTTP_POST_VARS[$k] = stripslashes($v); $HTTP_POST_VARS[$k] = mysql_escape_string($HTTP_POST_VARS[$k]); } else { $HTTP_POST_VARS[$k] = mysql_escape_string($v); } eval( "\$$k = \"$HTTP_POST_VARS[$k]\";" ); }

« previous php.general (#98840) next »