Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

1.3K
Views
ER_PARSE_ERROR node.js and mysql issue (INSERT INTO)

I want to do a simple insert with Node.js while I am using socket.io with node.js and MySQL. Don't know why, but I am geting this 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 ''markos'' at line 1

My code:
When I try this, I get the above error.

io.on("connection", function(socket){
console.log("a user is connected " + socket.id );


    socket.on("question", function (question){

        let sql = "INSERT INTO nodeJs (name) VALUES ?";

        con.query(sql, question, function (err) {
            if (err) throw err;
            console.log("1 record inserted");
        });


    });

  });
});

if I try this simple code, everything works fine:

io.on("connection", function(socket){
console.log("a user is connected " + socket.id );


    socket.on("question", function (question){

        let sql = "INSERT INTO nodeJs (name) VALUES ('John')";

        con.query(sql, function (err) {
            if (err) throw err;
            console.log("1 record inserted");
        });

    });

 });
});

The question parameter always has a string.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

You're missing the parentheses around the values:

let sql = "INSERT INTO nodeJs (name) VALUES (?)";
// Here ------------------------------------^-^
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!