提问者:小点点

ER_PARSE_ERROR:您的SQL语法中有错误


我试图在mysql中选择一行,其中我的变量req.body.email位于列Email_Address中,这是我的代码片段

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



});

但下面有一个错误

错误:CODEER_PARSE_ERROR:SQL语法中有错误;查看与MariaDB服务器版本相对应的手册,以确定使用靠近'@gmail.com'第1行/code>的正确语法

有什么解决办法吗


共1个答案

匿名用户

您需要将添加到电子邮件参数change中

con.query("select * from people where Email_address= "+ req.body.email

con.query("select * from people where Email_address= '"+ req.body.email +"'"