Problem with php (or apache) on my G5

rennat

Registered
I use "web sharing" to test my PHP instead of uploading after every change. Here is a problem I have had since I got my G5.
the server (php or apache I'm not sure) will not recognize variables sent in the URL (not sure of the correct name.) like:

index.php?var=foo

On my old system and when I upload to my server it creates a variable called $var and give it "foo" for a value.

on my current server if index.php contained

echo $var;

it would not print anything, in fact it thinks the variable doesn't exist.

does anyone know what could be causing this? or has anyone else had a similar problem? this has happened on two separate G5's now. (mine and a friends)

thank you for your time.

-oh and i did turn on PHP, things like includes or anything not involving a sent variable works-
 
since php 5 the register_globals options is turn to off by default, so $_GET["foo"] and $foo are different variables, if you turn on this option, the variables are the same.
and this is even for $_SESSION, $_POST etc...
 
the change occurred in php 4.2

from php.net
Perhaps the most controversial change in PHP is when the default value for the PHP directive register_globals went from ON to OFF in PHP 4.2.0.
 
Turn register_globals OFF again! It's a security risk, which is why it's turned off by default. Get used to using $_GET["foo"] instead, or use "extract($_GET)" or "import_request_variables".

The "extract($_GET)" will create local variables with the same names as the keys in $_GET, and then assign the corresponding values to them. These are local variables, so changing them won't affect the values in $_GET.

The function import_request_variables will import all keys from GET/POST/Cookie, and create variables using those names as references to the values in $_GET. You can choose which variables to import by supplying any combination of the letters g p or c (for GET, POST and Cookie respectively), the order defines which variables to keep if there are identical keys in two or more of the arrays. The last letter is the one that is kept, so 'gp' would mean that POST variables overwrite GET variables if the names are identical. You can also prepend variable names if you want, by suppling a prefix when you call the function. Remember that these are not local variables, but references to the variables in $_GET, so if you change the value of one of them, it will affect $_GET too!

Check the manual:
http://www.php.net/import_request_variables
 
elander said:
Turn register_globals OFF again!
yes, you are right, but this is a problem if you are developing for a webserver that uses old php version (and they are a lot)...
my suggestion:
first, check if the php version of the webserver where you have to put your final project supports these variables and then, if so, use the globals in off mode
 
Back
Top