MySQL PHP adding a backslash/escaping apostrophes Solution -

MySQL PHP adding a backslash/escaping apostrophes Solution

The first thing to diagnose is what is actually in the database (use PHPMyAdmin or CLI).

You will of course either find that the backslash is either in the database or not.

If the backslash is in the database you probably have magic quotes gpc/runtime on and/or are calling the "addslashes()" function which does this.

If you are escaping your data with mysql_real_escape_string() then think again, you probably have magic quotes gpc enabled either in php.ini or in an .htaccess

Most people will remember to check php.ini, but what if there is an old htaccess or one you did not remember.

In my case here is what I found:

php_flag magic_quotes_gpc off
php_flag magic_quotes_runtime on

Solution, turn off magic quotes runtime:

php_flag magic_quotes_gpc off
php_flag magic_quotes_runtime off

After that the problem should be solved.

Here is a thread where I think the answer may very well be mine in many cases.


  • ENOM how to do a 301 redirect to another domain/site
  • ENOM TRANSFER passwords do not match - solution
  • Linux how to check http headers using bash/curl for SEO
  • mdadm: CREATE group disk not found Incrementally started RAID arrays. Incrementally starting RAID arrays...
  • Linux SAMBA does not work with symlinks
  • How to Execute PHP in .html files with Apache in Linux Centos/Debian/Ubuntu etc
  • mdadm how to recover from failed drive
  • yum Packages skipped because of dependency problems:
  • Using a proxy with yum in Centos 6
  • How Do you Open/Extract .WARC Internet Archive Files on Linux Ubuntu/Mint/Centos?
  • How To Disable htaccess inheritance or exclude a directory
  • root/home directory has ownership changed to the wrong user/owner mysteriously
  • mdadm and lvm how to completely disable and remove vg/pv/lv
  • sshd[10470]: Authentication refused: bad ownership or modes for directory /root
  • LG Phoenix 2 Escape Disable AT&T Phonebook/Contacts Error Message
  • mdadm frozen and doesn't realize array is dead/missing failed due to unplugged drives
  • Unable to mount location Failed to retrieve share list from server: No such file or directory solution
  • mdadm how to make inactive array active
  • ImageMagick how to trim white space automatically in Linux
  • curl: (1) Protocol "https not supported or disabled in libcurl"