[PHP] Associative array key as a variable
Hi. I have the following PHP program executed from an HTML form where I pass the associative array key name as a variable: ? function show($name) { $cnt = count($HTTP_POST_VARS[$name]); echo Count for $name is $cnt; echo br /; } show(countries); show(cities); ? The result is always 0. The form fields do have name=countries[] and name=cities[] to indicate an array. When I hardcode the count line in the function as follows just to test to make sure the transfer from the browser works, it displays a correct non-zero result: $cnt = count($HTTP_POST_VARS[cities]); I even tried these statements in the function but all give a 0 result: $cnt = count($HTTP_POST_VARS[.$name.]); How do I get the count line to work with a variable in the function? Thanks, Eurico -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] HTTP_POST_VARS problem
Hi. I'm a newbie at this and am having problems understanding how this works. I have a form with method=post. The server program does display REQUEST_STRING as I expect (e.g., choice=yes but displaying HTTP_POST_VARS[choice] is null). However, displaying HTTP_GET_VARS[choice] does display yes. Running phpinfo() displays that the REQUEST_METHOD = GET. Why is this GET and how do I get it set to POST? How do I get HTTP_POST_VARS to work since my form does have method=post? Here are some php.ini settings (I'm running PHP 4.1.1 with Apache 1.3.22 under Win98): variables_order = EGPCS register_globals = On register_argc_argv = On gpc_order = GPC Thanks... Eurico [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] HTTP_POST_VARS problem
Please ignore my question - I just figured it out. I had the method=post in the input type=submit tag rather than in the form tag. It works! However, if one has an HTML select/option menu scrolling list with multiple selections, how does one get the number of values for the same name with HTTP_POST_VARS? Or how does one scroll through the list of choices passed? Thanks, Eurico [EMAIL PROTECTED] wrote: Hi. I'm a newbie at this and am having problems understanding how this works. I have a form with method=post. The server program does display REQUEST_STRING as I expect (e.g., choice=yes but displaying HTTP_POST_VARS[choice] is null). However, displaying HTTP_GET_VARS[choice] does display yes. Running phpinfo() displays that the REQUEST_METHOD = GET. Why is this GET and how do I get it set to POST? How do I get HTTP_POST_VARS to work since my form does have method=post? Here are some php.ini settings (I'm running PHP 4.1.1 with Apache 1.3.22 under Win98): variables_order = EGPCS register_globals = On register_argc_argv = On gpc_order = GPC Thanks... Eurico [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php