mardi 27 janvier 2015

Why is my delete where statement not working?

I am trying to delete a user from table USERS. Unfortunately, I keep getting sent to onSqlError. I can't figure out why. When I alert the request it gives me the correct name for the getTheId variable. Not too familiar with sql so maybe I have written something incorrectly. Any pointers appreciated.



// 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
}
});
}

Aucun commentaire:

Enregistrer un commentaire