I was wondering if it would be possible to escape certain characters in a string. In this case, the user enters a string and I wish to escape every quotation mark within the string. How would I go about doing this?
Thanks! Neil
hakre
4:25 pm on Feb 14, 2005 (gmt 0)
take a look here, i guess that's what you need: addslashes() [de2.php.net] ;) .
xeonaphobe
4:27 pm on Feb 14, 2005 (gmt 0)
Ooh, that'll do nicely :) Ty!
Neil
xeonaphobe
12:01 am on Feb 15, 2005 (gmt 0)
argh actually, no it won't. It's escaping everything nicely, the problem now is that whenever the user adds a comment with quotation marks in it, the escape character shows up when it's displayed. Is there anyway I can echo the string, but not the escapes? Or even just remove all the quotation marks altogether? Neil
to insert it into the database, use addslashes() like suggested, or even better mysql_real_escape_string() because this will insert the slashes into the table, you need to strip these before you echo out any of the contents with stripslashes()