Forum Moderators: coopster

Message Too Old, No Replies

Escaping certain characters

         

xeonaphobe

4:21 pm on Feb 14, 2005 (gmt 0)

10+ Year Member



Hi,

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)

WebmasterWorld Senior Member 10+ Year Member



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)

10+ Year Member



Ooh, that'll do nicely :) Ty!

Neil

xeonaphobe

12:01 am on Feb 15, 2005 (gmt 0)

10+ Year Member



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

Timotheos

1:17 am on Feb 15, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



stripslashes [de2.php.net]

Tim

dmmh

5:22 pm on Feb 15, 2005 (gmt 0)

10+ Year Member



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()