繁体   English   中英

ER_PARSE_ERROR:您的SQL语法有错误

[英]ER_PARSE_ERROR: You have an error in your SQL syntax

我试图在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');   
    }



});

但我在下面出现错误

错误: 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 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

关于如何解决它的任何想法

您需要在电子邮件参数中添加' ,更改

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

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM