I'm receiving SyntaxError: Invalid or unexpected token for the line:
var databaseQuery = "INSERT INTO userinfo
I was wondering if someone could help me format my code because this is my first time using MYSQL and javascript so I'm not sure why this isn't working or if I'm using the right format because I've seen different examples on google and wasn't sure which is the right way to write this.
app.post('/registration', urlencodedParser, function(req, res) {
console.log(req.body);
var databaseQuery = "INSERT INTO userinfo
(firstName,lastName,email,birthmonth,birthday,birthyear,university,country,state,zip,password)
VALUES ('"
+ req.body.firstName +"','"
+ req.body.lastName +"','"
+ req.body.email +"','"
+ req.body.birthmonth +"','"
+ req.body.birthday +"','"
+ req.body.birthyear +"','"
+ req.body.university +"','"
+ req.body.country +"','"
+ req.body.state +"','"
+ req.body.zip +"','"
+ req.body.password +"')";
connection.query(databaseQuery, function(err, result) {
if (err) {
throw err;
}else{
console.log(result.affectedRows + "records updated.");
}
}
res.render('registration', {qs: req.query});
});