[PHP] global env variables not working in php-cgi
I am migrating a site to a new host (westhost.com) and having some issues. PHP was compiled as a cgi instead of a module which is what I have always used. This wasn't really an issue until I realized a lot of my scripts that depended on apaches environment variables ($REQUEST_URI, $HTTP_USER_AGENT, etc.) weren't working. I can write a PERL cgi script and get them from the command line, they also appear in phpinfo(), yet I simply can't obtain them from any of my php scripts. Maybe the cgi issue isn't even related but up to this point it is the only culprit I can find. After spending three days going through the docs at apache, phpbuilder, and php.net I have not ran across anything which offers a solution. Thus, I am not looking in the right place or this is a unique problem. Can anyone out there help, or provide some directions/suggestions? And yes, they are running Apache (note above, I can obtain the variables but just not through my php scripts). Do I need to make an addition to my .htaccess file of some sort? I need these variables for my site to work properly ( css generation, hashing URL strings, etc.) so any/all help is greatly appreciated. If you need more information please let me know and I will get back to you as soon as possible. At this point I can't obtain ANY of the env variables (SERVER_PORT, REMOTE_ADDR, REQUEST_URI, HTTP_USER_AGENT, etc.). Thanks, //frank -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] global env variables not working in php-cgi
What version of PHP? I ask because a few test functions aren't available on older versions of PHP4. Try this piece of code: $arr = get_defined_vars(); print_r($arr); (if that doesn't work, try print_r($GLOBALS), but be sure to hit the Stop button on your browser, because it will print off an infinite list) Now, look at the results. In the main listing, does it list any of the ENV variables you are trying to access? If not, page down a bit and look in the HTTP_SERVER_VARS array. Are the ENV variables in there? My guess is that they probably are. Check phpinfo() again and see what register_globals is On. That may be your problem... If none of the variables you seek are in HTTP_SERVER_VARS, then something is wrong with the installation of PHP itself. -- Plutarck Should be working on something... ...but forgot what it was. "Franklin Hays" [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... I am migrating a site to a new host (westhost.com) and having some issues. PHP was compiled as a cgi instead of a module which is what I have always used. This wasn't really an issue until I realized a lot of my scripts that depended on apaches environment variables ($REQUEST_URI, $HTTP_USER_AGENT, etc.) weren't working. I can write a PERL cgi script and get them from the command line, they also appear in phpinfo(), yet I simply can't obtain them from any of my php scripts. Maybe the cgi issue isn't even related but up to this point it is the only culprit I can find. After spending three days going through the docs at apache, phpbuilder, and php.net I have not ran across anything which offers a solution. Thus, I am not looking in the right place or this is a unique problem. Can anyone out there help, or provide some directions/suggestions? And yes, they are running Apache (note above, I can obtain the variables but just not through my php scripts). Do I need to make an addition to my .htaccess file of some sort? I need these variables for my site to work properly ( css generation, hashing URL strings, etc.) so any/all help is greatly appreciated. If you need more information please let me know and I will get back to you as soon as possible. At this point I can't obtain ANY of the env variables (SERVER_PORT, REMOTE_ADDR, REQUEST_URI, HTTP_USER_AGENT, etc.). Thanks, //frank -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] global env variables not working in php-cgi
Hello. The version is php-4.02 built on Sep 22, 2000. |What version of PHP? I ask because a few test functions aren't available on |older versions of PHP4. | |Try this piece of code: | |$arr = get_defined_vars(); | |print_r($arr); This gave me an error on get_defined_var() so I tried print_r($GLOBALS) and got a ton of output of the form: Array ( [PHP_SELF] = /test.php [HTTP_GET_VARS] = Array ( ) [HTTP_COOKIE_VARS] = Array ( ) [HTTP_SERVER_VARS] = Array ( [PHP_SELF] = /test.php ) [GLOBALS] = Array ( [PHP_SELF] = /test.php [HTTP_GET_VARS] = Array ( ) [HTTP_COOKIE_VARS] = Array ( ) [HTTP_SERVER_VARS] = Array ( [PHP_SELF] = | /test.php ) [GLOBALS] = Array ( [PHP_SELF] = /test.php [HTTP_GET_VARS] = Array ( ) [HTTP_COOKIE_VARS] = Array ( ) [HTTP_SERVER_VARS] = Array (|(if that doesn't work, try print_r($GLOBALS), but be sure to hit the Stop [PHP_SELF] = /test.php ) [GLOBALS] = Array ( [PHP_SELF] = /test.php [HTTP_GET_VARS] = Array ( ) [HTTP_COOKIE_VARS] = Array ( ) [HTTP_SERVER_VARS]|button on your browser, because it will print off an infinite list) | = Array ( [PHP_SELF] = /test.php ) [GLOBALS] = Array ( [PHP_SELF] = /test.php [HTTP_GET_VARS] = Array ( ) [HTTP_COOKIE_VARS] = Array ( )|Now, look at the results. In the main listing, does it list any of the ENV [HTTP_SERVER_VARS] = Array ( [PHP_SELF] = /test.php ) [GLOBALS] = Array ( [PHP_SELF] = /test.php [HTTP_GET_VARS] = Array ( ) [HTTP_COOKIE_VARS]|variables you are trying to access? | = Array ( ) [HTTP_SERVER_VARS] = Array ( [PHP_SELF] = /test.php ) [GLOBALS] = Array ( [PHP_SELF] = /test.php [HTTP_GET_VARS] = Array ( )|If not, page down a bit and look in the HTTP_SERVER_VARS array. Are the ENV [HTTP_COOKIE_VARS] = Array ( ) [HTTP_SERVER_VARS] = Array ( [PHP_SELF] = /test.php ) [GLOBALS] = Array ( [PHP_SELF] = /test.php [HTTP_GET_VARS]|variables in there? | = Array ( ) [HTTP_COOKIE_VARS] = Array ( ) [HTTP_SERVER_VARS] = Array ( [PHP_SELF] = /test.php ) [GLOBALS] = Array ( [PHP_SELF] = /test.php|My guess is that they probably are. Check phpinfo() again and see what |register_globals is On. That may be your problem... [HTTP_GET_VARS] = Array ( ) [HTTP_COOKIE_VARS] = Array ( ) [HTTP_SERVER_VARS] = Array ( [PHP_SELF] = /test.php ) [GLOBALS] = Array ( [PHP_SELF]| = /test.php [HTTP_GET_VARS] = Array ( ) [HTTP_COOKIE_VARS] = Array ( ) [HTTP_SERVER_VARS] = Array ( [PHP_SELF] = /test.php ) [GLOBALS] = Array (|If none of the variables you seek are in HTTP_SERVER_VARS, then something is [PHP_SELF] = /test.php [HTTP_GET_VARS] = Array ( ) [HTTP_COOKIE_VARS] = Array ( ) [HTTP_SERVER_VARS] = Array ( [PHP_SELF] = /test.php ) [GLOBALS]|wrong with the installation of PHP itself. | | = Array ( [PHP_SELF] = /test.php [HTTP_GET_VARS] = Array ( ) [HTTP_COOKIE_VARS] = Array ( ) [HTTP_SERVER_VARS] = Array ( [PHP_SELF] = /test.php )| |-- [GLOBALS] = Array ( [PHP_SELF] = /test.php [HTTP_GET_VARS] = Array ( ) [HTTP_COOKIE_VARS] = Array ( ) [HTTP_SERVER_VARS] = Array ( [PHP_SELF] =|Plutarck |Should be working on something... /test.php ) [GLOBALS] = Array ( [PHP_SELF] = /test.php [HTTP_GET_VARS] = Array ( ) [HTTP_COOKIE_VARS] = Array ( ) [HTTP_SERVER_VARS] = Array (|...but forgot what it was. | [PHP_SELF] = /test.php ) [GLOBALS] = Array ( [PHP_SELF] = /test.php [HTTP_GET_VARS] = Array ( ) [HTTP_COOKIE_VARS] = Array ( ) [HTTP_SERVER_VARS]| | = Array ( [PHP_SELF] = /test.php ) [GLOBALS] = Array ( [PHP_SELF] = /test.php [HTTP_GET_VARS] = Array ( ) [HTTP_SERVER_VARS] = Array ( [PHP_SELF] = /test.php ) [GLOBALS] = Array ( [PHP_SELF] = /test.php [HTTP_GET_VARS] = Array ( ) [HTTP_COOKIE_VARS]| = Array ( ) [HTTP_SERVER_VARS] = Array ( [PHP_SELF] = /test.php ) [GLOBALS] = Array ( [PHP_SELF] = /test.php [HTTP_GET_VARS] = Array ( )| I am migrating a site to a new host (westhost.com) and having some [HTTP_COOKIE_VARS] = Array ( ) [HTTP_SERVER_VARS] = Array ( [PHP_SELF] = /test.php ) [GLOBALS] = Array ( [PHP_SELF] = /test.php [HTTP_GET_VARS]| issues. PHP was compiled as a cgi instead of a module which is what I = Array ( ) [HTTP_COOKIE_VARS] = Array ( ) [HTTP_SERVER_VARS] = Array ( [PHP_SELF] = /test.php ) [GLOBALS] = Array ( [PHP_SELF] = /test.php| have always used. This wasn't really an issue until I realized a lot of [HTTP_GET_VARS] = Array ( ) [HTTP_COOKIE_VARS] = Array ( ) [HTTP_SERVER_VARS] = Array ( [PHP_SELF] = /test.php ) [GLOBALS] = Array ( [PHP_SELF]| my scripts that depended on apaches environment variables ($REQUEST_URI, = /test.php [HTTP_GET_VARS] = Array ( ) [HTTP_COOKIE_VARS] = Array ( ) [HTTP_SERVER_VARS] = Array ( [PHP_SELF] = /test.php ) [GLOBALS] = Array (| $HTTP_USER_AGENT, etc.) weren't working. I can write a PERL cgi script [PHP_SELF] = /test.php [HTTP_GET_VARS] = Array ( ) [HTTP_COOKIE_VARS] = Array ( ) [HTTP_SERVER_VARS] = Array ( [PHP_SELF] = /test.php ) [GLOBALS] Something may be amiss with my hosts setup yet I have no idea what that may be. Any suggestions? I have never configured PHP to run as a cgi and have never had trouble getting global server variables.
Re: [PHP] global env variables not working in php-cgi
Btw, the reason you got all the output is why I said to hit the browser Stop button. Technically it will run forever. The GLOBALS array contains an a array called GLOBALS, which contains GLOBALS, endlessly. It will never ever end ;) It's fixed in 4.0.2. get_defined_vars isn't available till 4.0.4, so that's why you got the error. But from looking at your output, there is definately something screwy with their setup. In phpinfo, what are the settings for track_vars (if listed) and global_vars? "Franklin Hays" [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Hello. The version is php-4.02 built on Sep 22, 2000. |What version of PHP? I ask because a few test functions aren't available on |older versions of PHP4. | |Try this piece of code: | |$arr = get_defined_vars(); | |print_r($arr); This gave me an error on get_defined_var() so I tried print_r($GLOBALS) and got a ton of output of the form: Array ( [PHP_SELF] = /test.php [HTTP_GET_VARS] = Array ( ) [HTTP_COOKIE_VARS] = Array ( ) [HTTP_SERVER_VARS] = Array ( [PHP_SELF] = /test.php ) [GLOBALS] = Array ( [PHP_SELF] = /test.php [HTTP_GET_VARS] = Array ( ) [HTTP_COOKIE_VARS] = Array ( ) [HTTP_SERVER_VARS] = Array ( [PHP_SELF] = | /test.php ) [GLOBALS] = Array ( [PHP_SELF] = /test.php [HTTP_GET_VARS] = Array ( ) [HTTP_COOKIE_VARS] = Array ( ) [HTTP_SERVER_VARS] = Array (|(if that doesn't work, try print_r($GLOBALS), but be sure to hit the Stop [PHP_SELF] = /test.php ) [GLOBALS] = Array ( [PHP_SELF] = /test.php [HTTP_GET_VARS] = Array ( ) [HTTP_COOKIE_VARS] = Array ( ) [HTTP_SERVER_VARS]|button on your browser, because it will print off an infinite list) | = Array ( [PHP_SELF] = /test.php ) [GLOBALS] = Array ( [PHP_SELF] = /test.php [HTTP_GET_VARS] = Array ( ) [HTTP_COOKIE_VARS] = Array ( )|Now, look at the results. In the main listing, does it list any of the ENV [HTTP_SERVER_VARS] = Array ( [PHP_SELF] = /test.php ) [GLOBALS] = Array ( [PHP_SELF] = /test.php [HTTP_GET_VARS] = Array ( ) [HTTP_COOKIE_VARS]|variables you are trying to access? | = Array ( ) [HTTP_SERVER_VARS] = Array ( [PHP_SELF] = /test.php ) [GLOBALS] = Array ( [PHP_SELF] = /test.php [HTTP_GET_VARS] = Array ( )|If not, page down a bit and look in the HTTP_SERVER_VARS array. Are the ENV [HTTP_COOKIE_VARS] = Array ( ) [HTTP_SERVER_VARS] = Array ( [PHP_SELF] = /test.php ) [GLOBALS] = Array ( [PHP_SELF] = /test.php [HTTP_GET_VARS]|variables in there? | = Array ( ) [HTTP_COOKIE_VARS] = Array ( ) [HTTP_SERVER_VARS] = Array ( [PHP_SELF] = /test.php ) [GLOBALS] = Array ( [PHP_SELF] = /test.php|My guess is that they probably are. Check phpinfo() again and see what |register_globals is On. That may be your problem... [HTTP_GET_VARS] = Array ( ) [HTTP_COOKIE_VARS] = Array ( ) [HTTP_SERVER_VARS] = Array ( [PHP_SELF] = /test.php ) [GLOBALS] = Array ( [PHP_SELF]| = /test.php [HTTP_GET_VARS] = Array ( ) [HTTP_COOKIE_VARS] = Array ( ) [HTTP_SERVER_VARS] = Array ( [PHP_SELF] = /test.php ) [GLOBALS] = Array (|If none of the variables you seek are in HTTP_SERVER_VARS, then something is [PHP_SELF] = /test.php [HTTP_GET_VARS] = Array ( ) [HTTP_COOKIE_VARS] = Array ( ) [HTTP_SERVER_VARS] = Array ( [PHP_SELF] = /test.php ) [GLOBALS]|wrong with the installation of PHP itself. | | = Array ( [PHP_SELF] = /test.php [HTTP_GET_VARS] = Array ( ) [HTTP_COOKIE_VARS] = Array ( ) [HTTP_SERVER_VARS] = Array ( [PHP_SELF] = /test.php )| |-- [GLOBALS] = Array ( [PHP_SELF] = /test.php [HTTP_GET_VARS] = Array ( ) [HTTP_COOKIE_VARS] = Array ( ) [HTTP_SERVER_VARS] = Array ( [PHP_SELF] =|Plutarck |Should be working on something... /test.php ) [GLOBALS] = Array ( [PHP_SELF] = /test.php [HTTP_GET_VARS] = Array ( ) [HTTP_COOKIE_VARS] = Array ( ) [HTTP_SERVER_VARS] = Array (|...but forgot what it was. | [PHP_SELF] = /test.php ) [GLOBALS] = Array ( [PHP_SELF] = /test.php [HTTP_GET_VARS] = Array ( ) [HTTP_COOKIE_VARS] = Array ( ) [HTTP_SERVER_VARS]| | = Array ( [PHP_SELF] = /test.php ) [GLOBALS] = Array ( [PHP_SELF] = /test.php [HTTP_GET_VARS] = Array ( ) [HTTP_SERVER_VARS] = Array ( [PHP_SELF] = /test.php ) [GLOBALS] = Array ( [PHP_SELF] = /test.php [HTTP_GET_VARS] = Array ( ) [HTTP_COOKIE_VARS]| = Array ( ) [HTTP_SERVER_VARS] = Array ( [PHP_SELF] = /test.php ) [GLOBALS] = Array ( [PHP_SELF] = /test.php [HTTP_GET_VARS] = Array ( )| I am migrating a site to a new host (westhost.com) and having some [HTTP_COOKIE_VARS] = Array ( ) [HTTP_SERVER_VARS] = Array ( [PHP_SELF] = /test.php ) [GLOBALS] = Array ( [PHP_SELF] = /test.php [HTTP_GET_VARS]| issues. PHP was compiled as a cgi instead of a module which is what I = Array ( ) [HTTP_COOKIE_VARS] = Array ( ) [HTTP_SERVER_VARS] = Array ( [PHP_SELF] = /test.php ) [GLOBALS] = Array ( [PHP_SELF] = /test.php| have always used. This wasn't really an issue until I realized a lot of [HTTP_GET_VARS] = Array ( ) [HTTP_COOKIE_VARS] = Array ( ) [HTTP_SERVER_VARS] = Array ( [PHP_SELF] = /test.php )
Re: [PHP] global env variables not working in php-cgi
The GLOBALS array contains an a array called GLOBALS, which contains GLOBALS, endlessly. It will never ever end ;) It's fixed in 4.0.2. That was a typo. What I mean to say is that it's fixed in 4.0._4_, not _2_. -- Plutarck Should be working on something... ...but forgot what it was. ""Plutarck"" [EMAIL PROTECTED] wrote in message 9bf39j$j2c$[EMAIL PROTECTED]">news:9bf39j$j2c$[EMAIL PROTECTED]... Btw, the reason you got all the output is why I said to hit the browser Stop button. Technically it will run forever. The GLOBALS array contains an a array called GLOBALS, which contains GLOBALS, endlessly. It will never ever end ;) It's fixed in 4.0.2. get_defined_vars isn't available till 4.0.4, so that's why you got the error. But from looking at your output, there is definately something screwy with their setup. In phpinfo, what are the settings for track_vars (if listed) and global_vars? "Franklin Hays" [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Hello. The version is php-4.02 built on Sep 22, 2000. |What version of PHP? I ask because a few test functions aren't available on |older versions of PHP4. | |Try this piece of code: | |$arr = get_defined_vars(); | |print_r($arr); This gave me an error on get_defined_var() so I tried print_r($GLOBALS) and got a ton of output of the form: Array ( [PHP_SELF] = /test.php [HTTP_GET_VARS] = Array ( ) [HTTP_COOKIE_VARS] = Array ( ) [HTTP_SERVER_VARS] = Array ( [PHP_SELF] = /test.php ) [GLOBALS] = Array ( [PHP_SELF] = /test.php [HTTP_GET_VARS] = Array ( ) [HTTP_COOKIE_VARS] = Array ( ) [HTTP_SERVER_VARS] = Array ( [PHP_SELF] = | /test.php ) [GLOBALS] = Array ( [PHP_SELF] = /test.php [HTTP_GET_VARS] = Array ( ) [HTTP_COOKIE_VARS] = Array ( ) [HTTP_SERVER_VARS] = Array (|(if that doesn't work, try print_r($GLOBALS), but be sure to hit the Stop [PHP_SELF] = /test.php ) [GLOBALS] = Array ( [PHP_SELF] = /test.php [HTTP_GET_VARS] = Array ( ) [HTTP_COOKIE_VARS] = Array ( ) [HTTP_SERVER_VARS]|button on your browser, because it will print off an infinite list) | = Array ( [PHP_SELF] = /test.php ) [GLOBALS] = Array ( [PHP_SELF] = /test.php [HTTP_GET_VARS] = Array ( ) [HTTP_COOKIE_VARS] = Array ( )|Now, look at the results. In the main listing, does it list any of the ENV [HTTP_SERVER_VARS] = Array ( [PHP_SELF] = /test.php ) [GLOBALS] = Array ( [PHP_SELF] = /test.php [HTTP_GET_VARS] = Array ( ) [HTTP_COOKIE_VARS]|variables you are trying to access? | = Array ( ) [HTTP_SERVER_VARS] = Array ( [PHP_SELF] = /test.php ) [GLOBALS] = Array ( [PHP_SELF] = /test.php [HTTP_GET_VARS] = Array ( )|If not, page down a bit and look in the HTTP_SERVER_VARS array. Are the ENV [HTTP_COOKIE_VARS] = Array ( ) [HTTP_SERVER_VARS] = Array ( [PHP_SELF] = /test.php ) [GLOBALS] = Array ( [PHP_SELF] = /test.php [HTTP_GET_VARS]|variables in there? | = Array ( ) [HTTP_COOKIE_VARS] = Array ( ) [HTTP_SERVER_VARS] = Array ( [PHP_SELF] = /test.php ) [GLOBALS] = Array ( [PHP_SELF] = /test.php|My guess is that they probably are. Check phpinfo() again and see what |register_globals is On. That may be your problem... [HTTP_GET_VARS] = Array ( ) [HTTP_COOKIE_VARS] = Array ( ) [HTTP_SERVER_VARS] = Array ( [PHP_SELF] = /test.php ) [GLOBALS] = Array ( [PHP_SELF]| = /test.php [HTTP_GET_VARS] = Array ( ) [HTTP_COOKIE_VARS] = Array ( ) [HTTP_SERVER_VARS] = Array ( [PHP_SELF] = /test.php ) [GLOBALS] = Array (|If none of the variables you seek are in HTTP_SERVER_VARS, then something is [PHP_SELF] = /test.php [HTTP_GET_VARS] = Array ( ) [HTTP_COOKIE_VARS] = Array ( ) [HTTP_SERVER_VARS] = Array ( [PHP_SELF] = /test.php ) [GLOBALS]|wrong with the installation of PHP itself. | | = Array ( [PHP_SELF] = /test.php [HTTP_GET_VARS] = Array ( ) [HTTP_COOKIE_VARS] = Array ( ) [HTTP_SERVER_VARS] = Array ( [PHP_SELF] = /test.php )| |-- [GLOBALS] = Array ( [PHP_SELF] = /test.php [HTTP_GET_VARS] = Array ( ) [HTTP_COOKIE_VARS] = Array ( ) [HTTP_SERVER_VARS] = Array ( [PHP_SELF] =|Plutarck |Should be working on something... /test.php ) [GLOBALS] = Array ( [PHP_SELF] = /test.php [HTTP_GET_VARS] = Array ( ) [HTTP_COOKIE_VARS] = Array ( ) [HTTP_SERVER_VARS] = Array (|...but forgot what it was. | [PHP_SELF] = /test.php ) [GLOBALS] = Array ( [PHP_SELF] = /test.php [HTTP_GET_VARS] = Array ( ) [HTTP_COOKIE_VARS] = Array ( ) [HTTP_SERVER_VARS]| | = Array ( [PHP_SELF] = /test.php ) [GLOBALS] = Array ( [PHP_SELF] = /test.php [HTTP_GET_VARS] = Array ( ) [HTTP_SERVER_VARS] = Array ( [PHP_SELF] = /test.php ) [GLOBALS] = Array ( [PHP_SELF] = /test.php [HTTP_GET_VARS] = Array ( ) [HTTP_COOKIE_VARS]| = Array ( ) [HTTP_SERVER_VARS] = Array ( [PHP_SELF] = /test.php ) [GLOBALS] = Array ( [PHP_SELF] = /test.php [HTTP_GET_VARS] = Array ( )| I am migrating a site to a new host (westhost.com) and having some [HTTP_COOKIE_VARS] = Array ( ) [HTTP_SERVER_VARS] = Array (
Re: [PHP] global env variables not working in php-cgi
|But from looking at your output, there is definately something screwy with |their setup. | |In phpinfo, what are the settings for track_vars (if listed) and |global_vars? track_vars is set to ON for local and master. register_globals is set to ON for local and master. there isn't a listing for global_vars. should there be? Is there something I can set witn ini_set that will enable these variables? Thanks, //frank -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]