Re: HTTP_POST_VARS gives odd results
| From: | Jason Lavigne | Date: | Wed, 29 Nov 2000 04:51:37 +0000 |
| Subject: | Re: HTTP_POST_VARS gives odd results | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-27618@lists.php.net to get a copy of this message | ||
Try:
$HTTP_POST_VARS["addr"] = $newvalue1;
$HTTP_POST_VARS["city"] = $newvalue2;
and do not use the reset.
Jay
----- Original Message -----
From: "Janet Valade" <janetv@systech.com>
To: <php-general@lists.php.net>
Sent: Tuesday, November 28, 2000 11:40 AM
Subject: [PHP] HTTP_POST_VARS gives odd results
> I have the following code which doesn't seem to give me the results I
> expect.
>
> if ($testvar == "other") {
> $newvalue1="string1";
> $newvalue2="string2";
> $HTTP_POST_VARS[addr] = $newvalue1;
> $HTTP_POST_VARS[city] = $newvalue2;
> }
>
> reset($HTTP_POST_VARS);
>
> while (list($key,$value) = each($HTTP_POST_VARS)) {
> echo "key, value = $key, $value<Br>";
>
> if (empty($$key) ) {
> do stuff;
> else
> do other stuff;
> }
> }
>
> The above while loop works perfectly without the code before it. However,
> when I add the code before it that changes the values of some of the
> elements in HTTP_POST_VARS, it no longer works. The values were changed
> successfully, the echo in the loop shows the correct changed values of
> string1 and string2 for $key,$value. However, when it gets to the if
(empty)
> statement, it is evaluated as empty (its previous value) and do stuff is
> done, rather than do other stuff. The elements of HTTP_POST_VARS that were
> not changed still are evaluated correctly by the if empty statement; only
> the changed elements are evaluated incorrectly. Clearly, I am not
> understanding something about HTTP_POST_VARS. Can someone tell me what I
am
> doing wrong?
>
> Janet
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>