I have a problem with mysql_real_escape_string and addslashes. I have a form in my PHP file where it is $_POST['title'], then I have:
$title = mysql_real_escape_string(addslashes($_POST['title']));
And I insert $title into my db. When I want to get this value from my db I have:
$title = stripslashes($results['title']);
Problem is when I submit something like this: abs"'@, my result is: abs\"\'@.
I don’t know where the bug is.
Don’t bother using
addslashesat all,mysql_real_escape_stringis more than capable of doing it on its own. So use:And remove the
stripslashesfrom your retrieval code. If the problem persists, you probably have one of themagic_quotesoptions on – if so, turn it off!