I am fetching some contents from Google Feeds API using JavaScript API and trying to insert them into a SQLite database in a Phonegap app.
But I get so many syntax errors due to non escaped and special characters in the fetched content string. Because the content string has HTML codes and their attributes and their values within quotes.
Can anybody help me with a solution to get this task done? Can somebody suggest me ways to perform the PHP functions like addslashes, htmlentities, htmlspecialchars? Let me know a proper way to do this insertion. Only JS.
Eg:
The inserting variable "content" is a string with <div id="test" style="color:#000;">I'm tall and I'm "26" now.</div> and it needs to be inserted to a column, the html content without any error.
var content = <div id="test" style="color:#000;">I'm tall and I'm "26" now.</div>
tx.executeSql("INSERT INTO MyTable(id, Content) VALUES ('1',content)");
The variable "content" has single and double quotes and further it can contain many special characters. So the content variable must be formatted before inserting to DB.