I'm having issues escaping/stripping strings with PHP/MySQL - there always seems to be redundant slashes.
Let's take the following string as an example:
When adding a string to the database, I'm escaping it with
mysql_real_escape_string() and the following gets stored in the database (EDIT: checked this by querying the database directly with mysql app):
When reading back out of the database, I'm passing the string through
stripslashes() and the following is returned:
Since the quotes are still escaped, it breaks the html and the text is not underlined.
- Why is
mysql_real_escape_string()adding three slashes, and
stripslashes()removing two slashes? I would expect them both to add/remove one slash.
- How can I prevent this from happening?
- Am I approaching this the correct way?