When A customer enters " ' " (apostrophe) in their name PHP adds it like this Laura L\\\'Herault . Note 3 slashes. When I use stripslashes PHP removes only 2 slashes and output is Laura L\'Herault What to do to fix this problem. Thanks in advance. GreatLogix
So the user writes Laura l'Herault in the form. Your script receives it through $_POST or $_GET and when you echo that value it shows Laura L\\\'Herault? With three slashes? Are you sure you didn't do any validation that might have added two slashes?
Yes original name is Laura L'Herault. I am using POST. No addslashes. I am saving data in MySQL DB. In data base its in this format Laura L\\\'Herault and on reports page after stripslashes its Laura L\'Herault
Nope it can't happen unless you are addslashing, if so, don't do (your server must be setup to add them automatically). What is actually happening is that you are submitting the form more than 1 time, each time, it'll add 1 slash you do and the one is done automatically. When you post the text on the form input, use strip-slashes before displaying it, it should fix it (new, not add-ons, which must be done manually). If else, post your code here (or pm) and I'll fix it for you. Peace,
Are you using mysql_real_escape_string when you enter it into the database? I think I had the same problem as you and it was because of mysql_real_escape_string.
Your problem is probably caused because your server has magic quotes enabled. Before doing anything with the user input, even passing it through mysql_real_escape_string, pass it through a function like this: function checkinput ($value) { if (get_magic_quotes_gpc()) { return stripslashes($value); } else { return $value; } } PHP:
Thanks CreativeClans and all it works. I did not notice there was addslashes call in the script. Nice code snippet. Thanks. Green rep to all