开发者

How to avoid saving escape character (\) in db

开发者 https://www.devze.com 2022-12-31 17:10 出处:网络
I\'m using zend frame work zend form and zend db for my project. The problem I have is, when the user ent开发者_StackOverflow社区er some special characters in the text field (i.e \"I\'m\"), it is sav

I'm using zend frame work zend form and zend db for my project.

The problem I have is, when the user ent开发者_StackOverflow社区er some special characters in the text field (i.e "I'm"), it is saved in the database with the "\" character (i.e. "I\'"). I need to know how to fix this so it just saved as whatever the user entered.


You need to disable magic-quotes.


http://www.php.net/manual/en/security.magicquotes.disabling.php

If you cannot for any reason disable them you can use stripslashes to strip those \ when getitng the data out of the db before echoing it to the browser.


Use stripslashes(trim($value)); to strip the \ and remove the extra spaces.

0

精彩评论

暂无评论...
验证码 换一张
取 消