How to avoid saving escape character (\) in db
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.
精彩评论