add slashes and strip slashes
I have noticed a strange thing in PHP hosted under windows 2003.
I use addslashes function to remove any single quotes before inserting input data to db. Then I need to use stripslashes function while displaying it.
If I use
str_replace("'", "\'", $str_input)
instead of addslashes, I don't have to use stripslashes function. A single quote is getting inserted as a single quote itself in this case. Where as when I use addslashes, it is getting added as \' into the database.
I thought the above statement and addslashes are doing the same thing.
May I know why this is happening ? Is there any automatic replacement of single quotes ?