how to escape my database content?
Posted: Sun Jan 23, 2005 10:44 am
Hello
I have some string which I get from the database called $string
I need to pass this string to a javascript function like so:
The problem here is that the string may contain any character including single or double quotes. This will cause a JavaScript error if not handled properly
I was wondering what would be the correct and robust way to escape the string so it won't interfere with string escaping in HTML and JavaScript
regards
I have some string which I get from the database called $string
I need to pass this string to a javascript function like so:
Code: Select all
<a href="#" onclick="func('<?php echo $string; ?>');">test</a>I was wondering what would be the correct and robust way to escape the string so it won't interfere with string escaping in HTML and JavaScript
regards