sdm Posted July 8, 2006 Share Posted July 8, 2006 I have a site which I built sometime ago using PHP, it stopped working so I asked my host what the problem was.This was their response:"In this case we would like to let you know that several months ago the configuration on the servers was changed as php default setting was to have safe_mode enabled, it appears that your site has not registered the variables you are using so is conflicting with the safe_mode setting within php. It should also be noted that in future releases of php it is not possible to have it turned off.It is pretty straight forward to register the variables in the script, best thing to do is just search in google.com ......"I can't seem to find a good answer in Google, could someone help me out please.Thanks,SDM Quote Link to comment https://forums.phpfreaks.com/topic/14022-can-someone-explain-this-to-me-about-variables-please/ Share on other sites More sharing options...
GingerRobot Posted July 8, 2006 Share Posted July 8, 2006 I could be wrong, but im guessing that this is all to do with register_globals...if you have a form with a text field such as:<input type="text" name="firstname">with register_globals on you could access the value from the field simply by using $firstname - the firstname variable has automatically been created.With register_globals off, you would have to use the $_POST array:$firstname = $_POST[firstname; Quote Link to comment https://forums.phpfreaks.com/topic/14022-can-someone-explain-this-to-me-about-variables-please/#findComment-54766 Share on other sites More sharing options...
wildteen88 Posted July 8, 2006 Share Posted July 8, 2006 Your host appears to be talking out of thier arse! AFAIK safe_mode doesnt affect variables at all. But what I think they was supposed to say was register globals rather than safe mode!Register globals is the setting that affect variables the most. Now if they have disabled register_globals then any data you are retrieving from a form, or from the url, sessions or cookies will not work. As currently you are most probably doing something like this:[code]<?phpif($name){ echo "Your name is $name";}?><form action="" method="post">Name: <input type="text" name="name" value="Your name"><br /><input type="submit" name="submit" value="Submit"></form>[/code]Which will work if register_globals is enabled. However when register_globals is disabled you'll need to use the superglobal arrays. The superglobal arrays are the following: $_POST, $_GET, $_COOKIE, $_SESSION etc,So with the code above. Rather than using $name to get the users name when they submit the form you use $_POST['name'] instead. Or if use the GET method you use $_GET.$_COOKIE and $_SESSION are straight forward as they hold the cookie and session data etc.There a few more superglobal arrays however the five listed above are the most common. Quote Link to comment https://forums.phpfreaks.com/topic/14022-can-someone-explain-this-to-me-about-variables-please/#findComment-54769 Share on other sites More sharing options...
sdm Posted July 8, 2006 Author Share Posted July 8, 2006 Thanks for your assistance, the site in question has been altered and is now working correctly.SDM Quote Link to comment https://forums.phpfreaks.com/topic/14022-can-someone-explain-this-to-me-about-variables-please/#findComment-54794 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.