phpfastcgimagic-quotes-gpc

PHP 5.3 magic_quotes_gpc On but not working


I've a problem with magic_quotes_gpc. I'm migrating a webserver from an XP machine to a Win2003 one. PHP code is in some cases old, and not really well developed, so I really need to have magic_quotes_gpc working.

I'm pretty sure that configurations were made properly, I've also tryed copying old PHP folder and php.ini, but still have the problem. Having magic_quotes_gpc = On have the exact behavior of having it magic_quotes_gpc = Off.

Tryied with PHP 5.3 but even with the older 5.1 working properly on the old server.

The only difference is that in the new server I use FastCGI.

I'm really in your hands to solve this, I'm really getting crazy!

20140326 - Add code example as per Alvaro suggestion

<?
  print $_GET["id"];
  print '<br><br>';
  print $_GET[id];
?>

Calling page ./sample.php?id=1, only this line is displayed (I've errors on):

PHP Notice: Use of undefined constant id - assumed 'id' in C:\Inetpub\wwwroot\simple.php on line 4

Commenting line 4:

<?
  print $_GET["id"];
  print '<br><br>';
  //print $_GET[id];
?>

Output is 1 as expected.


Solution

  • Your test code is totally unrelated to magic quotes thus I suspect you've misunderstood what the feature does. With magic quotes, you'd call this URL:

    /test.php?foo=O'Hara
    

    ... where test.php is:

    <?php
    var_dump($_GET);
    

    ... and get this back:

    array(1) {
      ["foo"]=>
      string(7) "O\'Hara"
    }
    

    ... instead of this:

    array(1) {
      ["foo"]=>
      string(6) "O'Hara"
    }
    

    However, you are attempting to use a non-existing constant, as here:

    <?php
    define('this_exists', 'yes');
    echo this_exists;
    echo this_does_not_exist;
    

    ... and you possibly want that PHP does not warn you about the error:

    PHP Notice: Use of undefined constant this_does_not_exist - assumed 'this_does_not_exist'

    So you basically want to fiddle with error_reporting and omit E_NOTICE.