2010-10-22

How to turn off php magic quotes on nearlyfreespeech.net

I recently set up a web app hosted on nearlyfreespeech.net that uses mysql_real_escape_string to to escape user input. I noticed the other day that an entry in that web app displayed an escaped single quote, which led me to suspect that nearlyfreespeech.net has PHP magic quotes turned on and my user input was being double escaped, which turned out to be correct. Here is how I turned off magic quotes for web app on nearlyfreespeech.net:

  • I connected to my nearlyfreespeech.net account via SSH.
  • I navigated to the public directory of my account (where the html and php files are).
  • At the command prompt I ran nano .htaccess to create a .htaccess file and open it in nano for editing
  • I put this in the .htaccess file: php_flag magic_quotes_gpc off
  • I saved the file, and voila, magic quotes were off!

2 comments:

abrah.am said...

Thanks. Just what I was looking for.

Unknown said...

this also worked great for me! Wonderful and thanks!


(anytips of safe mode can be turned off) ?