gpt4 book ai didi

javascript - 为什么我的删除语句不起作用?

转载 作者:行者123 更新时间:2023-12-03 10:58:46 25 4
gpt4 key购买 nike

我正在尝试从表 USERS 中删除用户。不幸的是,我总是被发送到 onSqlError。我不明白为什么。当我发出请求时,它会为我提供 getTheId 变量的正确名称。对sql不太熟悉,可能写错了。任何指示表示赞赏。

// DELETE RECORD
function deleteRecord(getTheId){
deleteUser.onclick = (function () {//deleteUser is an element generated for each user when a button is clicked
var sqlStr2 = 'DELETE FROM USERS WHERE username = '+getTheId+'';
alert("SQL: " + sqlStr2); //This gives me the statement above with the correct name of the user clicked.
if (db){
console.log("db is there");//this logs
db.transaction(function(tx) {
tx.executeSql(sqlStr2);
}, onSqlError, onSqlSuccess); //THEN I GET SENT TO ERROR
}
});
}

最佳答案

试试这个:

var sqlStr2 = "DELETE FROM USERS WHERE username = '"+getTheId+"'";

关于javascript - 为什么我的删除语句不起作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28176068/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com