Jump to content

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.

Thanks,

SDM
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;
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]<?php
if($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.
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.