【发布时间】:2018-07-14 11:24:42
【问题描述】:
我正在尝试在 mysql 中选择一行,其中我的变量 req.body.email 位于 Email_Address 列中 这是我的代码 sn-p
app.post('/login', function(req, res){
con.query("select * from people where Email_address= "+ req.body.email, (err, res) => {
if(err) {
console.log('the email '+ req.body.email +'does not exist in the database');
throw err;
}
else{
console.log('selected');
if(password == req.body.password)
//res.redirect('index', { title: 'Hey', message: 'Hello there!' });
res.send('hello');
}
});
但我在下面收到错误
错误:ER_PARSE_ERROR: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '@gmail.com' at line 1
关于如何解决它的任何想法
【问题讨论】:
-
通过添加找到它: var queryy = "select * from people where Email_address=? "; con.query(queryy,[req.body.email], (err, res) => {...}
标签: javascript mysql node.js