PDA

View Full Version : Strip error giving chars


chrisvmarle
04-25-2003, 08:50 PM
I have a quote-system on my page where visitors can post some comment. I want to filter the characters that might give problems like "

The var is later used in javascript:
startscroll("form01.vq","<?=$vqs?>")

So if $vqs contains a "
the JS will look like this:
startscroll("form01.vq","test quote with " in it")
Wich will result in a JS-error...

Is there a PHP-function to strip there characters?
I've tried htmlspecialchars but then the quote looks like
test quote with &quot in it

Thanks
Mzzl, Chris

firepages
04-26-2003, 12:55 AM
you can str_replace() any chars you want , but perhaps better still to, addslashes() in PHP , then unescape() ( js is rusty but I think thats the function ?) in javascript ?

chrisvmarle
04-26-2003, 12:00 PM
Thanks the addslashes() is enough :)

Mzzl, Chris