I’m inserting data into the browser’s HTML5 database (SQLite I believe) however I am getting a strange error when inserting a time string.
When I inspect the object in the debugger this is what I see: endTime:"15:00"
However, when it goes to insert the entire object into the local DB, it says syntax error near "15":
for(i in jobs) {
tx.executeSql("INSERT INTO job (id,name,startTime,endTime,clientName,started,comments,locationName,address,city,province) VALUES
("+jobs[i].jobId+",'"+jobs[i].name+"','"+jobs[i].startTime+"'','"+jobs[i].endTime+"','"+jobs[i].clientName+"',"+jobs[i].started+",'"+jobs[i].comments+"'','"+jobs[i].locationName+"','"+jobs[i].address+"','"+jobs[i].city+"','"+jobs[i].province+"'')");
}
Why would this trigger an error!? Do I need to escape something or change my syntax? Thanks!
Ok this was a misinterpretation of the error. Surprised I didn’t catch it earlier.
After looking very closely, I realized that there’s an extra
'beforeendTime. This is probably due to an autocompletion by Aptana Studio.Unfortunately these errors aren’t too helpful but I shall look more closely next time!