Should I try to rid my MySQL database of back
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:
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".
would turning magic_quotes_gpc off prevent the occurrence of the back-slashes?
Probably yes.
is the prevention of these back-slashes in the database desirable?
Yes. They serve no purpose. If you use PDO and properly parametrized queries, the problem that magic quotes used to address is already solved.
See the PHP manual on magic quotes on why they were used, and why they should no longer be used.
链接地址: http://www.djcxy.com/p/64802.html上一篇: 未找到物业
下一篇: 我应该尝试摆脱我的MySQL数据库的背面