0

enter image description here

header 1 header 2
cell 1 cell 2
cell 3 cell 4
app.post('/success', function (req, res) {

    var con = mysql.createConnection({
        host: "localhost",
        user: "root",
        password: "",
        database: 'project'
    })
    const id = 1;
    con.query("SELECT * FROM orders WHERE id = ${id}", (err, result) => {
        username = req.session.username
        res.render('pages/success', { result: result, username: username });
        //res.send("hello")
    })
})

display payment receipt

Barmar
  • 741,623
  • 53
  • 500
  • 612
  • You should check the `err` result -- that would have told you that there was a syntax error in the query and you might have figured out the problem on your own. – Barmar Mar 30 '23 at 16:07

1 Answers1

0

The use of template literal is wrong, please correct following line

 con.query("SELECT * FROM orders WHERE id = ${id}", (err, result) => {

to

 con.query(`SELECT * FROM orders WHERE id = ${id}`, (err, result) => {

we are updating Quotation-mark(") to literals(`). for more about template-literals