PDA

View Full Version : PHP location-bar variables don't work with personal web sharing




FattyMembrane
Jul 14, 2004, 10:33 PM
i just enabled PHP on my installation of 10.3 and although it works, it will not process variables passed in the location bar. for example, if my site index.php has a link to href="index.php?option=2"

mycomp.local/index.php?option=2

refreshes, but the page stays exactly the same, option=2 is not processed. if i upload the files to my webserver, everything works fine. as you can imagine, this is crippling my sites, and makes my built-in webserver pretty close to useless. any help would be appreciated.



Knox
Jul 15, 2004, 09:00 AM
One thing to check is whether you are using global variables, or using the $_GET array to access the variables. The default appears to be that register_globals is off on OS X, whereas your webserver admin may have switched them back on for compatibility.

http://www.php.net/manual/en/security.globals.php

sonofslim
Jul 15, 2004, 09:19 AM
Knox is right. try running the following script from both your local server and your live server:<? phpinfo(); ?>

you should see a line in the output that looks like the screen-grab i've attached. if your local server says "Off" and your live server says "On," then there's your problem. register_globals Off, by the way, is the recommended way to run your scripts.

msharp
Jul 15, 2004, 09:33 AM
Knox is right. try running the following script from both your local server and your live server:<? phpinfo(); ?>

you should see a line in the output that looks like the screen-grab i've attached. if your local server says "Off" and your live server says "On," then there's your problem. register_globals Off, by the way, is the recommended way to run your scripts.
yeah, turn the Register Global Variables to "On" rather than "Off" by default in the php.ini

sonofslim
Jul 15, 2004, 10:21 AM
yeah, turn the Register Global Variables to "On" rather than "Off" by default in the php.ini

if you want to mirror your live server's behavior exactly, that is. for discussion on why you might want to leave it off, see the following threads. in a nutshell, writing your scripts under the assumption that register_globals is off is more secure. plus they'll work exactly the same as if register_globals is on, so there's no reason not to.

http://forums.macrumors.com/showthread.php?t=63196&highlight=register_globals
http://forums.macrumors.com/showthread.php?t=50823
http://forums.macrumors.com/showthread.php?t=61406&highlight=register_globals

FattyMembrane
Jul 17, 2004, 10:26 AM
thanks for all of the responses. changing the line in my php.ini file worked like a charm.