如何逃跑?正在插入到sqlite数据库的数据。 [英] How to escape? data that is being inserted into sqlite database.
本文介绍了如何逃跑?正在插入到sqlite数据库的数据。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用电话差距(使用sqlite数据库)。苹果应用程序。
I'm making an apple app using phone gap (which uses sqlite database).
所有我的插件工作正常,除非当我尝试插入一个weblink。
All my inserts work fine except for when I try to insert a weblink. This errors because there are " characters in the weblink.
使用以下操作:
var content = 'hello, this is my <a href="www.google.com">link</a>'
tx.executeSql('UPDATE PAGES SET content="'+content+'" WHERE id="1"');
返回以下错误
error code 1
error: "near "http": syntax error"
如果我删除网站地址,我没有得到一个错误我试过:
content = escape(content);
If I remove the website address, I don't get an error. I have tried: content = escape(content);
但是没有效果。
推荐答案
使用参数绑定正确和最安全的方式做你想做的事情。
Use parameter binding. This is the right and the safest way to do what you're trying to do.
tx.executeSql('UPDATE PAGES SET content=? WHERE id=1', [content]);
这篇关于如何逃跑?正在插入到sqlite数据库的数据。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文