简体   繁体   English

从sqlite数据库中获取结果

[英]fetch results from sqlite database

i want to get the location from specific user and when i run this code it gets me error ' Uncaught TypeError: Cannot read property 'location' of undefined ' and i dont know how i can fixed. 我想从特定用户那里获取位置,当我运行此代码时,我得到了错误信息'Uncaught TypeError:无法读取未定义的属性'location',我不知道该如何解决。 this is the code : 这是代码:

db.transaction(function(tx){
     tx.executeSql("SELECT location FROM users WHERE username='"+username+"'",[], success ); 
});

function success(tx,results){
     var city = results.rows.item[0].location;
}

在result.rows上调用item时,您使用的是方括号而不是括号。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM