Piesel

Mysql don't connect

Recommended Posts

Hello! Mysql dosen't work on my server, i don't have any logs in the console from mysql connection.

 

Code;

 

var mysql = require('mysql');
 
var bcrypt = require('bcrypt-nodejs');
 
var conn = mysql.createConnection({
host:'replaced',
user:'replaced',
password:'replaced',
database:'replaced'
});
 
conn.connect(function (err) { console.log('Got connected'); });

 

Share this post


Link to post
Share on other sites
conn.connect(function(err) {
  if (err) console.log (err);
  else console.log("Successful connected to DataBase!");
});

so you will get error in console

Share this post


Link to post
Share on other sites

Dude we cant read your code from here. People can help you only if you share with us all your code line associated with your problem.

Share this post


Link to post
Share on other sites

 

 

Everything from this folder. And yes, I have a mysql module

index.js

require('./main.js');

require('./main_s.js');

 

 

 

 

main.js

 

mp.events.addCommand("v", (player) => {

player.outputChatBox('Dostępne komendy związane z samochodami prywatnymi');

player.outputChatBox('/vspawn [id]');

player.outputChatBox('/vlista');

player.outputChatBox('/vudostepnij [id_gracza] [id_pojazdu]');

player.outputChatBox('/vprzypisz [id pojazdu] [id grupy]');

player.outputChatBox('/vulepszenia [id_pojazdu]');

});

 

mp.events.addCommand("vlista", (player) => {

mp.events.call('sprawdzPojazd', player);

console.log(`dziala`);

});

 

mp.events.add('wypiszPojazdy', (player) => {

let pojazdy = player.getVariable(`pojazd_gracz`);

let id = player.getVariable(`id_pojazdow`);

player.outputChatBox(`Twoje pojazdy:`);

player.outputChatBox(`${id} ${pojazdy}`);

});


 

 

 

 

 

main_s.js

var mysql = require('mysql');

 

var conn = mysql.createConnection({

host:'re',// host of server

user:'re',// MySQL user

password:'re',// MySQL password

database:'re'// MySQL database

});

 

conn.connect(function(err) {

if (err) console.log (err);

else console.log("Successful connected to DataBase!");

});

 

mp.events.add('sprawdzPojazd', (player) => {

console.log(`wykonany event`)

conn.query("SELECT * from `rp_vehicles` WHERE `login`=", [player], function(e, r) {

if(e) {

console.log('Error on connection ... ');

throw e;

}

else {

console.log(`wykonany event2`);

player.setVariable('pojazd_gracz', r[0].model);

player.setVariable('id_pojazdow', r[0].id);

mp.events.call('wypiszPojazdy', player);

}

});

});

Edited by Piesel

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.