In the process of populating a javascript array via a db query, using php, I am running in to a problem with escaping characters that are special to javascript ( ; , / ' " ) etc. If the the string from the database is free of javascript special characters all is great! Being that the field being queried is based on user input, I would like to escape all the javascript special characters using a php string function before i put the value in the javascript array. I want to do this for security reasons as well as keeping the javascript from breaking if a user inputs a single quote (') in their input.
I've searched the internet for a php function that will make a javascript safe string to no avail (i'm prolly using the wrong keywords). Anyway, if anyone has any ideas about how to do this please let me know. Thank you for your time.
Matt