Error: ER_PARSE_ERROR: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE id = '1'' at line 1
at Query.Sequence._packetToError (D:\Softwares\usermana\Nodejs-UserManagement-Express-Hbs-MySQL\node_modules\mysql\lib\protocol\sequences\Sequence.js:47:14)
at Query.ErrorPacket (D:\Softwares\usermana\Nodejs-UserManagement-Express-Hbs-MySQL\node_modules\mysql\lib\protocol\sequences\Query.js:79:18)
at Protocol._parsePacket (D:\Softwares\usermana\Nodejs-UserManagement-Express-Hbs-MySQL\node_modules\mysql\lib\protocol\Protocol.js:291:23)
at Parser._parsePacket (D:\Softwares\usermana\Nodejs-UserManagement-Express-Hbs-MySQL\node_modules\mysql\lib\protocol\Parser.js:433:10)
at Parser.write (D:\Softwares\usermana\Nodejs-UserManagement-Express-Hbs-MySQL\node_modules\mysql\lib\protocol\Parser.js:43:10)
at Protocol.write (D:\Softwares\usermana\Nodejs-UserManagement-Express-Hbs-MySQL\node_modules\mysql\lib\protocol\Protocol.js:38:16)
at Socket.<anonymous> (D:\Softwares\usermana\Nodejs-UserManagement-Express-Hbs-MySQL\node_modules\mysql\lib\Connection.js:88:28)
at Socket.<anonymous> (D:\Softwares\usermana\Nodejs-UserManagement-Express-Hbs-MySQL\node_modules\mysql\lib\Connection.js:526:10)
at Socket.emit (node:events:390:28)
at addChunk (node:internal/streams/readable:315:12)
--------------------
at Protocol._enqueue (D:\Softwares\usermana\Nodejs-UserManagement-Express-Hbs-MySQL\node_modules\mysql\lib\protocol\Protocol.js:144:48)
at Connection.query (D:\Softwares\usermana\Nodejs-UserManagement-Express-Hbs-MySQL\node_modules\mysql\lib\Connection.js:198:25)
at exports.update (D:\Softwares\usermana\Nodejs-UserManagement-Express-Hbs-MySQL\server\controllers\userController.js:81:14)
at Layer.handle [as handle_request] (D:\Softwares\usermana\Nodejs-UserManagement-Express-Hbs-MySQL\node_modules\express\lib\router\layer.js:95:5)
at next (D:\Softwares\usermana\Nodejs-UserManagement-Express-Hbs-MySQL\node_modules\express\lib\router\route.js:144:13)
at Route.dispatch (D:\Softwares\usermana\Nodejs-UserManagement-Express-Hbs-MySQL\node_modules\express\lib\router\route.js:114:3)
at Layer.handle [as handle_request] (D:\Softwares\usermana\Nodejs-UserManagement-Express-Hbs-MySQL\node_modules\express\lib\router\layer.js:95:5)
at D:\Softwares\usermana\Nodejs-UserManagement-Express-Hbs-MySQL\node_modules\express\lib\router\index.js:284:15
at param (D:\Softwares\usermana\Nodejs-UserManagement-Express-Hbs-MySQL\node_modules\express\lib\router\index.js:365:14)
at param (D:\Softwares\usermana\Nodejs-UserManagement-Express-Hbs-MySQL\node_modules\express\lib\router\index.js:376:14) {
code: 'ER_PARSE_ERROR',
errno: 1064,
sqlMessage: "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE id = '1'' at line 1",
sqlState: '42000',
index: 0,
sql: "UPDATE user SET username = 'sk_shabbir_', email = '[email protected]', password = '1234', WHERE id = '1'"
}
The data from user table:
undefined
Im trying to update my login detatils dynamically from the admin page but it throws an error when I click on submit
Heres my database structure
[this is the code for the function][1]
[1]: https://i.stack.imgur.com/ONZpK.png
CodePudding user response:
You have comma before "where" that mustn't be there. Just remove it.
CodePudding user response:
In your code there is an extra single quotation mark please remove that.
after the question mark ?'
What is the code right now?
WHERE id = ?' ,
What should be the code?
WHERE id = ? ,