Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

196
Vistas
SQL Parse Error Using JavaScript with Express and MySQL

I am trying to make a log in system. Right now I am working on allowing the user to register. I am trying to make it so you can't create an account that has the same username or email as another. However, it is giving me a parse error.

Here is the code:

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");
            }
          }
        );
      }
    };
});

Here is the error I am getting:

{
  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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda