Hey All,

My local server is causing me hassle again!

I turned global variables on in php.ini
register_globals = On

but the following code doesn't work

URL:
http://localhost/sites/test/var_test.php?test_var=TEST

test.php:
<? echo "Test Variable = ".$test_var; ?>

this just prints out
Test Variable =
instead of
Test Variable = TEST

if I change it to
<?
$test_var = $_GET['test_var'];
echo "Test Variable = ".$test_var;
?>

it works fine.

I know I should write my code to work with globals off but I have some old sites I want to edit and I cant face rewriting them!!

If anyone can help me I promise I will code properly from now on!! 🙂

Many Thanks

Al

    Stupid question but eh..

    Have you restarted the server since changing settings?

    J.

      Yup!

      And no its not a stupid question, the ammount of people in work that come upto me saying their printer doesnt work .... there is usually a simple question and answer.

      Al

        Any chance that you have multiple php.ini files and that maybe you edited the wrong one? Or perhaps an .htacess file is overriding the setting? You can use echo phpinfo() to verify the setting.

          You are right, something is overriding php.ini

          I did a search and I only have one php.ini file but phpinfo() says
          register_globals is Off (Local & Master)

          What could be overriding it? I did a search for .htaccess files but found none.

          I have restarted the server again ... no change to php_info()

            Check phpinfo() for the location of php.ini

              It says
              Configuration File (php.ini) Path C:\WINDOWS

              but its not there its in C:\WINDOWS\system

              Is this my prob? Do I move the php.ini file or change thae path somehow?

              Al

                If you are using Apache webserver, edit httpd.conf to set:
                PHPIniDir "C:/WINDOWS/system"

                Conversely, move php.ini to C:\WINDOWS

                  Thats it!

                  Many Thanks again Laserlight, Leatherback and Ahundiak

                  Al

                    Write a Reply...