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

No error is displayed nor does it show that the database has been connected

Share this post


Link to post
Share on other sites

Called.

 

			
			require('./main.js');				
			require('./main_s.js'); - there is a mysql.			
	

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
Posted (edited)

 

 

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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.