I'm using PDO prepared statements to insert data into a MySQL database, and I notice that apostrophes (single quotes) in strings are being stored in the database with back-slashes (\
) preceding them.
I use stripslashes($string)
on output, and of course this gets rid of them.
I searched my server's phpinfo()
information (PHP version 5.2.17) for "magic_quotes" and found:
- magic_quotes_gpc: local value = on, master value = on
- magic_quotes_runtime: local value = off, master value = off
- magic_quotes_sybase: local value = off, master value = off
Firstly, would turning magic_quotes_gpc off prevent the occurrence of the back-slashes? I don't currently have access to the server php.ini master settings, but as I understand it I would be able to disable it by configuring the root .htaccess file with the directive php_flag magic_quotes_gpc Off
.
Secondly, is the prevention of these back-slashes in the database desirable? I ask this because I saw the somewhat cryptic remark here to "think twice before you do".