Why isn't disabling magic quotes in php.ini taking effect? - php

I disabled magic quotes at the end of my php.ini file in my root directory and there was no change. I am still getting backslashes in front of single quotes in $_POST entries. So I put a php.ini file in the same directory as the PHP file being run and only included the lines disabling magic quotes, but there still isn’t any change.
What am I missing here?
PHP 5.3.24 on a GoDaddy shared server.
The php.ini file:
magic_quotes_gpc = Off
magic_quotes_runtime = Off
magic_quotes_sybase = Off

Note: As of php 7.4 this option is deprecated and it is removed in php 8.0
You could try it with a .htaccess file. You will need this line:
php_flag magic_quotes_gpc Off
As GoDaddy Shared Server doesn't accept this above option try this instead:
You have to make a file named like php5.ini and place this in the root folder. You can add just only the three lines you need or you can copy the php.ini file that you have on your local computer and edit the changes you want.

Related

php.ini PATH section has no effect

I am using PHP-FPM with Apache and try to set custom php.ini settings inside a [PATH=...] directive. For example:
[PATH=/var/www/mysite]
memory_limit = 512M
I placed the file into /etc/php/7.4/fpm/conf.d/99-mysite.ini
According to phpinfo() the file is being parsed and everything works if I leave out the [PATH]-part or use a [HOST=...] directive. Solely [PATH=...] is not being activated. Triple checked the path is correct.
My test file is saved in /var/www/mysite/htdocs/php.php so I also tried [PATH=/var/www/mysite/htdocs] in case this doesn't work recursivly but still it has no effect at all.
Any ideas on why [PATH=] doesn't seem to work at all?

PHP ignoring config file

I'm trying to turn off magic_quotes_gpc in PHP. I'm running PHP with Apache and Ubuntu.
I have in my config file (/etc/php5/apache2/php.ini):
magic_quotes_gpc Off
Where I create a page with phpinfo() it shows magic_quotes_gpc as on. I've also looked in Additional .ini files parsed and there is no setting for it.
Why is PHP ignoring this?
try to add/edit in php.ini
magic_quotes_gpc = Off
after adding restart your apache services for taking effect this
You can turn them off using .htaccess with:
php_flag magic_quotes_gpc Off
and also using php if writable php.ini
ini_set('magic_quotes_gpc' , 0 );
Firstly, it is deprecated so, don't rely on it. Mmmmmmmkay?
Secondly, Check
Loaded Configuration File
Under phpinfo()
Also Add :
php_flag magic_quotes_gpc Off to your .htaccess file.
Cool?
Did you recently make this change? If so, you have to restart PHP for it to take effect.

Cannot save article in Joomla 3.0 Magic Quotes issue

I am unable to save any article / module etc in Joomla 3.0. When I try to save the " " is replaced by "\"\"". This messes up all my code. I tried turning off the magic_quotes_gpc in php.ini but that did not help.
How do I fix this?
I presume you did the Joomla! 3 installation by adding the .htaccess with magic_quotes_gpc = off inside the install directory, to successfully install the platform, correct?
If your server is running php 5.3+ you need to set the server php configuration to magic_quotes_gpc = off. It should be configured as so since magic_quotes_gpc is deprecated in php 5.3 and will be removed in 5.4.
In summary, you can only overcome this issue by configuring the php on the server. No .htaccess will solve your problem, unless you place an .htaccess inside each and every directory on your Joomla! installation - which is unthinkable imo.
fixing the issue where adding \" during article posts in administrator panel:
magic_quotes_gpc = Off
magic_quotes_runtime = Off
magic_quotes_sybase = Off
Disable these options from your php.ini file.
You can also overwrite the php.ini.
Please check the link for overwriting the php.ini using .htaccess
How to turn off magic quotes on shared hosting?

How to turn off php safe_mode off for a particular directory in a shared hosting environment?

Hi I'm used shared hosting. I want to turn off php safe_mode off for my site. My provider gave me a php.ini file and asked me to put it with my settings in my public_html folder to override the settings, but it didn't work.
You can also try to create a file called php.ini in the root (public_html or other) folder, and putting the following in it:
safe_mode = Off
Depending on server settings, this may or may not work.
Your service provider might have forgot to tell you that you need to enable your user defined php.ini configuration by adding this line in the .htaccess file that you find in your public_html folder:
#Activates php.ini config located in main folder to work also recursively for all subfolders
suPHP_ConfigPath /home/YOUR_CPANEL_USER_NAME/public_html
Obviously replace YOUR_CPANEL_USER_NAME with your cPanel user name.
I'm supposing your server has got suPHP module(which is quite common in nowdays).
BTW: the php.ini file need to be in /home/YOUR_CPANEL_USER_NAME/public_html too and inside you should write this:
safe_mode = Off
And remember that Safe Mode is deprecated in PHP 5.3.0 and is removed in PHP 6.0.0.
TRY:
You can turn it off by adding the following line to a .htaccess file in your root (public html) folder.
If the .htaccess file doesn't exist, you can create it using a simple text editing program.
php_flag safe_mode Off

PHP.ini does not work

I opened the notepad, inserted 3 lines in it, saved it as php.ini, and uploaded it in public_html, but I am still getting an error that requires to first switch the magic quotes off. The syntax of the three lines is as following:
magic_quotes_gpc = 0
magic_quotes_runtime = 0
magic_quotes_sybase = 0
What am I doing wrong?
use phpinfo() function to see what php.ini file you're actually using
You can probably alter these settings in a .htaccess configuration file as well:
php_flag magic_quotes_gpc off
php_flag magic_quotes_runtime off
php_flag magic_quotes_sybase off
See PHP: How to change configuration settings.
Most hosting companies lets you define a local ini file. Check their support pages, and see where you should put your php.ini file for it to be read by the php engine. If they have an option for this, you don't have to worry about restarting the server.
If you can't find any info about it, create a page with the following code:
<?php phpinfo(); ?>
And look for the property named "Configuration File (php.ini) Path". This is where you should put the file.
It's not meant to be placed in the public_html folder... it should be in your PHP installation folder.
Php.ini is not usually located in public_html. If you can't access your real php.ini, try writing
php_flag magic_quotes_gpc off
in a .htaccess file (in public_html).
Most hosting companies won't let you play around with the php.ini unless you rent a dedicated server from them. On that, you could try on page php.ini settings like the following:
ini_set("magic_quotes_gpc", "0");
ini_set("magic_quotes_runtime", "0");
ini_set("magic_quotes_sybase", "0");
If that doesn't work, then you'll have to ask your hosting company about it.
On CentOS 8 run
service php-fpm restart
To read the edited php.ini file
Well, you have to change your main php.ini which I don't think is in public_html.
Moreover, in order to see the changes you have to restart your php engine.

Categories