Page 1 of 1

How do I insert a backslash every time there is an apostroph

Posted: Wed Oct 19, 2005 10:43 am
by Antek_Ryu
Hi All

I am trying to put in a backslash everytime I recieve text from a form that has apostraphies. I recieve this text that goes into the database and then my webpage displays the text. The webpage that displays the text uses javascript and the javascript will only accept apostrophies if it is backslashed. I have used the following


addbackslash();

but it doesnt do anything






Regards
Antek

Posted: Wed Oct 19, 2005 10:50 am
by Grim...
addslashes()

To get rid of the backslashes again, use stripslashes()

Posted: Wed Oct 19, 2005 10:52 am
by Antek_Ryu
Sorry I meant i put in addslashes() but it doesent put in slashes!

Posted: Wed Oct 19, 2005 11:01 am
by Antek_Ryu
Actually it does put in a slash for (") I want it to put in a slash for ('). How can I make it do that, thanks.

Posted: Wed Oct 19, 2005 11:06 am
by foobar

Code: Select all

$text = addcslashes($text, $charlist);
All chars in $charlist will be escaped in $text.

Posted: Wed Oct 19, 2005 9:08 pm
by Jenk
If using mysql, use mysql_real_escape_string()