Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sqlite/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript WebSQL:SQLite查询返回一个事务错误_Javascript_Sqlite - Fatal编程技术网

Javascript WebSQL:SQLite查询返回一个事务错误

Javascript WebSQL:SQLite查询返回一个事务错误,javascript,sqlite,Javascript,Sqlite,我正在尝试使用WebQlite执行SQL事务。我遇到的问题是,每次运行代码时,我都会收到一个SQL错误,它的状态是:SQLError{code:5,消息:“无法准备语句(1附近”)”:syntax error)} 仅从外观上看,我无法理解此错误的含义,因此我尝试将sql查询打印到控制台中,它返回以下内容:INSERT-into-propertiesList(reporterName、propertyType、bedrooms、datetime、furnitureTypes、MonthlyEntp

我正在尝试使用WebQlite执行SQL事务。我遇到的问题是,每次运行代码时,我都会收到一个SQL错误,它的状态是:
SQLError{code:5,消息:“无法准备语句(1附近”)”:syntax error)}

仅从外观上看,我无法理解此错误的含义,因此我尝试将sql查询打印到控制台中,它返回以下内容:
INSERT-into-propertiesList(reporterName、propertyType、bedrooms、datetime、furnitureTypes、MonthlyEntprice、notes、propertyLocation、images)
价值(‘以色列’、‘公寓’、‘工作室’、‘157049472000’、‘家具’、‘150000’、‘、’、‘)

另外,这是我的代码结构:

db.transaction(事务=>{
transaction.executeSql(
`如果不存在,则创建表propertiesList(
id整数主键自动递增,
reporterName文本不为空,
propertyType文本不为空,
卧室文本不为空,
日期时间文本不为空,
monthlyRentPrice文本不为空,
家具类型文本,
注释文本,
属性定位文本,
图像和文本,
)`
);
如果(重复===真){
msg='您有一个与此类似的详细信息的属性。请检查并更新它';
}否则{
const formData=new formData();
forEach(image=>formData.append('file[],image));
如果(imageArray.length>0){
轴心柱(`https://cors-anywhere.herokuapp.com/http://laratweet.me/upload_photos`,formData)。然后(响应=>{
console.log('来自上传图像',响应);
});
}否则{
让sql=`插入propertiesList(报表名称、propertyType、卧室、日期时间、家具类型、MonthlyEntPrice、备注、propertyLocation、图像)
值(${reporterName}、${propertyType}、${beddooms}、${datetime}、${furnitureTypes}、${monthlyRentPrice}、'${notes}、'${propertyLocation}、'${propertyLocation}、'');
console.log(sql);
transaction.executeSql(sql);
刷新属性列表(true);
let interval1=setInterval(()=>{
如果(列表类型!==未定义){
让数组=[];
for(设i=0;i
我的问题是,我不知道错误是什么,也不知道如何解决,现在我被困在这个项目上,因为除非“创建”功能起作用,否则我无法继续网站的任何部分。感谢您的帮助。提前感谢。

已修复

在创建表时,在“图像文本”后面的尾随逗号阻止了创建

executeSql(sql)(未引用数据库)

W3C在2010年停止了对Web SQL规范的积极维护,并且 没有计划进一步维护它。请参阅Web SQL数据库

我建议你使用

IndexedDB API功能强大,但对于简单的 案例。如果您希望使用简单的API,请尝试使用以下库 localfough、dexie.js、ZangoDB、pockdb、idb、idb-keyval和JsStore 这使得IndexedDB对程序员更加友好


这是一个学校项目,指南特别要求我们使用WebSQL,因此我无能为力that@IsraelObanijesu哦我会查的,谢谢。你想得太快了。我花了几个小时检查错误的位置:(对于
insert
查询,我不需要引用数据库,我可以在一个事务中运行多个查询。无论如何,感谢您找出逗号错误
var db = openDatabase('mydb', '1.0', 'Test DB', 2 * 1024 * 1024);
  db.transaction(tx => {
    tx.executeSql(
      `CREATE TABLE IF NOT EXISTS propertiesList (
          id INTEGER PRIMARY KEY AUTOINCREMENT,
          reporterName TEXT NOT NULL,
          propertyType TEXT NOT NULL,
          bedrooms TEXT NOT NULL,
          datetime TEXT NOT NULL,
          monthlyRentPrice TEXT NOT NULL,
          furnitureTypes TEXT,
          notes TEXT,
          propertyLocation TEXT,
          images TEXT
       )`
    );
  });

  let sql = `INSERT INTO propertiesList (reporterName, propertyType, bedrooms, datetime, furnitureTypes, monthlyRentPrice, notes, propertyLocation, images) 
        VALUES ('Israel', 'Flat', 'Studio', '1570494720000', 'Furnished', '150000', '', '', '')`;
  db.transaction(tx=>{
      tx.executeSql(sql)
  })