Answer the question
In order to leave comments, you need to log in
Error when looking up mysql2 node.js data?
Hello, I need to check if a record exists in a Mysql table using Node.JS.
To do this, I installed the Mysql2 module, connected everything, was able to connect to the database
const mysql = require("mysql2");
const connection = mysql.createConnection({
host: "localhost",
user: "root",
database: "stream",
password: ""
});
var uID = data.id;
var uNick = data.nickname;
var userD = [uID, uNick];
connection.query("SELECT * FROM users WHERE ('Login', 'ID') VALUES('?',?)", userD, function(err, result){
console.log(err);
console.log(result);
});
Answer the question
In order to leave comments, you need to log in
var userD = [uID, uNick];
Parameters are swapped. The SQL query comes first with Login (String) then ID (Number). You have the opposite. So he swears, about which he directly writes in an error.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question