Jump to content


This topic is now archived and is closed to further replies.


Can someone explain this to me about variables please

Recommended Posts

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.



Share this post

Link to post
Share on other sites
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;

Share this post

Link to post
Share on other sites
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:
  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">
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.

Share this post

Link to post
Share on other sites
Thanks for your assistance, the site in question has been altered and is now working correctly.


Share this post

Link to post
Share on other sites


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.