Forum Moderators: coopster

Message Too Old, No Replies

PHP Undefined Variables

         

lindajames

12:21 pm on Aug 8, 2004 (gmt 0)

10+ Year Member



I have scripts that run fine on many servers with PHP but for some reason on my server that i have just installed PHP on i keep getting undefined variable errors for almost all the common varibales like: $HTTP_REFERER, $HTTP_HOST, $PHP_SELF

I have the ISAPI module version of PHP installed

Birdman

12:31 pm on Aug 8, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Looks like you need to turn register_globals [php.net] 'On'. Or, access the variables in their full form:

$_SERVER['PHP_SELF']
$_SERVER['DOCUMENT_ROOT']
$_POST['form_field_name']
$_GET['query_string_var']
etc...

You can change the register_globals setting in your php.ini file or in your .htaccess file.

Birdman

encyclo

12:33 pm on Aug 8, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Most hosts leave Register Globals set to On, as there are a load of legacy scripts around that require it - however, the default setting is Off when you install PHP yourself.

coopster

8:02 pm on Aug 8, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



You said you just installed PHP, so I might assume you installed PHP 5.0.0?

As of PHP 5.0.0, the long PHP predefined variable arrays may be disabled with the register_long_arrays [php.net] directive. If you used the "recommended"

php.ini
file, the default installation has them turned Off. You may want to turn them back on for your test server...
; Whether or not to register the old-style input arrays, HTTP_GET_VARS 
; and friends. If you're not using them, it's recommended to turn them off,
; for performance reasons.
register_long_arrays = On

mincklerstraat

4:02 pm on Aug 9, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



for changing register globals via .htaccess file see [php.net...] - to get a look at the configuration options, see [php.net...] (though you don't want to use the function ini_set() for this one, it won't work).