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

210
Views
Error de análisis de SQL al usar JavaScript con Express y MySQL

Estoy tratando de hacer un registro en el sistema. En este momento estoy trabajando para permitir que el usuario se registre. Estoy tratando de hacerlo para que no puedas crear una cuenta que tenga el mismo nombre de usuario o correo electrónico que otra. Sin embargo, me está dando un error de análisis.

Aquí está el código:

 app.post("/create", (req, res) => { const email = req.body.email; const username = req.body.username; const password = req.body.password; db.query("SELECT email, username FROM users WHERE email = ? AND username = ?"), [email, username], (err, result) => { if (err) { console.log(err); } else if (result) { res.send("Username or Email is already in use.") } else { db.query( "INSERT INTO users (email, username, password) VALUES (?,?,?)", [email, username, password], (err, result) => { if (err) { console.log(err); } else { res.send("Values Inserted"); } } ); } }; });

Aquí está el error que estoy recibiendo:

 { code: 'ER_PARSE_ERROR', errno: 1064, sqlMessage: "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '? AND username = ?' at line 1", sqlState: '42000', index: 0, sql: 'SELECT email, username FROM users WHERE email = ? AND username = ?' }
about 4 years ago · Juan Pablo Isaza
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!