Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Escaping problem 2

Status
Not open for further replies.

Dweezel

Technical User
Feb 12, 2004
428
GB
When I'm retrieving data from a mysql database that is to be put into javascript (say an alert or document.write),if it's from a user inputed string I use addslashes to avoid causing any problems in the javascript.

Is there any method for escaping user created characters retrieved from a database that is to be included in HTML? My particular problem at the moment is apostrophes and double quotes. Addslashes deals with them in javascript, but obviously not in HTML.

I've done a search of the PHP functions in the manual with the word HTML to see if I could track anything down but I haven't found anything useful.

Can anyone help me out?

 
try htmlenties

Bastien

I wish my computer would do what I want it to do,
instead of what I tell it to do...
 
<script language="javascript">
document.write("demo for \"users\" ok");
</script>

Something like that will work fine!

Can you give a sample of the javascript that creates the error?
 
Thanks guys. Both answers have helped me.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top