Thursday, October 9, 2014

Turn off PHP magic quotes on shared hosting

I have a simple html form containing textarea and submit button. When I submit the form, PHP automatically escape all single quote. The problem happens only on shared hosting.

This problem caused by PHP's magic quotes. It's automatically turn on in my shared hosting.
So, how to turn it off?

Firstly, open the File Manager on your web hosting, and go to the root folder.
In my case, I go to the root folder for the subdomain.
Example: if the subdomain is guitar.example.com, then I go to public_html/chord folder.

Now, let's create "php.ini" file in this folder, then add this line
magic_quotes_gpc = Off

Then saves the file. That's all, magic quotes is off.

By the way, what is gpc? It stands for Get Post Cookie. So, it turns off magic quotes for Get, Post, Cookie variables.