7inage 4 Posted August 5 Good day, friends, help solve the problem. The fact is that MYSQL is connected, and the query is not executed at all. Does not write anything to the console. Help Sorry for my English var mysql = require('mysql'); let mysqlc = mysql.createConnection({ host: '...', user: '...', password: '...', database: '...' }); mysqlc.connect(function(e) { console.log('Connecting ... '); if(e) { console.log("Error connecting to the database with error "+e); } else { console.log('Database connected!') } }); mp.events.add("CheckedLogin", (UserName, Password) => { console.log('Call ... '); mysqlc.query("SELECT * FROM `Player` WHERE `UserName`=", [UserName], function(e, r) { console.log('Load ... '); if(e) { console.log('Error on connection ... '); throw e; } else { console.log('Password is '); } }); mysqlc.end(); }); The event call works, but after the query in the database, nothing works ... Thank! Share this post Link to post Share on other sites
LeonMrBonnie 5 Posted August 5 Remove the line : mysqlc.end(); This closes the mysql connection completely, which you probably don't want. Share this post Link to post Share on other sites
7inage 4 Posted August 5 10 минут назад, LeonMrBonnie сказал: Remove the line : mysqlc.end(); This closes the mysql connection completely, which you probably don't want. Nothing has changed, the request is still not executed. Share this post Link to post Share on other sites
LeonMrBonnie 5 Posted August 5 If it really does not write anything to the console try logging something at the very top of the file, to see if it is even loaded at all. If not, show us where you require that file. Share this post Link to post Share on other sites
7inage 4 Posted August 5 1 час назад, LeonMrBonnie сказал: If it really does not write anything to the console try logging something at the very top of the file, to see if it is even loaded at all. If not, show us where you require that file. Sorry for the error, the only thing he writes to the console is: console.log ('Call ...'); At the very beginning of the event, and I put the message in the console after mysqlc.query, he also writes, but everything in mysqlc.query cohd something passes by. Share this post Link to post Share on other sites
LeonMrBonnie 5 Posted August 6 Try this: (You forgot the ? placeholder at the end) "SELECT * FROM `Player` WHERE `UserName`=?" Share this post Link to post Share on other sites
7inage 4 Posted August 6 (edited) 3 часа назад, LeonMrBonnie сказал: Try this: (You forgot the ? placeholder at the end) "SELECT * FROM `Player` WHERE `UserName`=?" Everything is just as bad, the fact is that mysql does not even give out information about the connection, that is, it does not write errors, not that it successfully connects to the database and checks the call at the beginning of the connection, either ... Edited August 6 by 7inage Share this post Link to post Share on other sites
LeonMrBonnie 5 Posted August 6 Try wrapping your whole code into a try catch like this: try { var mysql = require('mysql'); let mysqlc = mysql.createConnection({ host: '...', user: '...', password: '...', database: '...' }); mysqlc.connect(function(e) { console.log('Connecting ... '); if(e) { console.log("Error connecting to the database with error "+e); } else { console.log('Database connected!') } }); mp.events.add("CheckedLogin", (UserName, Password) => { console.log('Call ... '); mysqlc.query("SELECT * FROM `Player` WHERE `UserName`=", [UserName], function(e, r) { console.log('Load ... '); if(e) { console.log('Error on connection ... '); throw e; } else { console.log('Password is '); } }); mysqlc.end(); }); } catch(e) { console.log(e); } Share this post Link to post Share on other sites
7inage 4 Posted August 6 8 минут назад, LeonMrBonnie сказал: Try wrapping your whole code into a try catch like this: try { var mysql = require('mysql'); let mysqlc = mysql.createConnection({ host: '...', user: '...', password: '...', database: '...' }); mysqlc.connect(function(e) { console.log('Connecting ... '); if(e) { console.log("Error connecting to the database with error "+e); } else { console.log('Database connected!') } }); mp.events.add("CheckedLogin", (UserName, Password) => { console.log('Call ... '); mysqlc.query("SELECT * FROM `Player` WHERE `UserName`=", [UserName], function(e, r) { console.log('Load ... '); if(e) { console.log('Error on connection ... '); throw e; } else { console.log('Password is '); } }); mysqlc.end(); }); } catch(e) { console.log(e); } Nothing has changed, but when I did not enter the data for the connection, I got errors and console.log ('Connecting ...') was called, but when I put my data for the connection, everything returned to its place Share this post Link to post Share on other sites
7inage 4 Posted August 6 @LeonMrBonnie Thank you for trying to help, I decided the problem was not in the code, but in the base to which I was connecting ... It is in the KNOB parameter. Share this post Link to post Share on other sites