2
votes

I tried to turn off magic quotes in these places: /etc/php5/apache2/php.ini /etc/php5/cli/php.ini I'm sure all of them is "Off".

but it's still ON in phpinfo()! Here is my phpinfo()

magic_quotes_gpc    On  On
magic_quotes_runtime    Off Off
magic_quotes_sybase Off Off

The only way it works is add php_flag magic_quotes_gpc Off to .htaccess.

Now I want to disable it in php.ini. How can???

Edit:

phpinfo() shows:

Configuration File (php.ini) Path   /etc/php5/apache2
Loaded Configuration File   /php.ini

so I opened /etc/php5/apache2/php.ini. These are the magic-quotes-related things:

magic_quotes_gpc = Off

; Magic quotes for runtime-generated data, e.g. data from SQL, from exec(), etc.
; http://php.net/magic-quotes-runtime
magic_quotes_runtime = Off

; Use Sybase-style magic quotes (escape ' with '' instead of \').
; http://php.net/magic-quotes-sybase
magic_quotes_sybase = Off
2
Have you restarted your server after doing these changes?Yogesh Suthar
Yes after one change, I restart Apache2emeraldhieu
Is it your local server or main live server like godaddy?Yogesh Suthar
You should restart PHP as well... sudo service php5-fpm restartmax_
Perhaps you're editing the wrong ini file? Look at the output of phpinfo and note down the file mentioned in "Loaded Configuration File".Salman A

2 Answers

1
votes

php.ini's settings should be respected by PHP, so if the default value is also reported to be 'On', PHP probably failed to read the value from your .ini file.

Here's what to do:

  1. Share with us the line of config that you added to your php.ini to disable it. It may be the case that you just made a typo. It should look something like this.

    magic_quotes_gpc = Off
    magic_quotes_runtime = Off
    magic_quotes_sybase = Off
    
  2. Make sure that there aren't multiple occurrences of magic_quotes_gpc in your ini file(s)!

  3. Make sure you're editing the correct .ini file(s)! Open your phpinfo()'s output, and look at the "Configuration File (php.ini) Path" and "Additional .ini files parsed". Check these files for an entry of magic_quotes_gpc.

    • Note that it may differ whether you run phpinfo() on the CLI or using your web server!
  4. Although this is very unlikely to be the issue considering what you say phpinfo() reported, ensure that you are not overriding stuff in your web server's configuration.

0
votes

Use this function in your php file, it will works

set_magic_quotes_runtime(false);

Note

This function has been DEPRECATED as of PHP 5.3.0 and REMOVED as of PHP 5.4.0.