Answer the question
In order to leave comments, you need to log in
I threw the application into apk, an error connecting to the database, although it works in the browser, what should I do?
db = mysql.createConnection({
host: 'localhost',
//socketPath: "/var/run/mysqld/mysqld.sock",
user : 'root',
password : '',
database : 'game'
});
db.connect((err) => {
if(err) console.log(err);
console.log("Mysql connected");
});
db.query('SELECT email FROM players WHERE email=?', [email], (err,result,fields) => {
if(err) console.log(err);
e_mail = fields[0];
console.log(JSON.stringify(e_mail));
});
if(e_mail == undefined) {
socket.emit('warning');
}
else {
console.log(e_mail + '/' + email);
db.query("INSERT INTO players (nickname,email) VALUES('" + nick + "','" + email + "')", (err,result) => {
if(err) console.log(err);
console.log("Insert");
});
}
Answer the question
In order to leave comments, you need to log in
What and where did you put it?
Your connection to the database goes through localhost. Accordingly, nothing will connect if you do not have mysql installed on the device, or connect via an external IP for the DBMS
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question