Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. var mysql = require('mysql');
  2.  
  3. var mysqlc = mysql.createConnection(
  4. {
  5. host:'localhost',// host of server
  6. user:'root',// MySQL user
  7. password:'root',// MySQL password
  8. database:'vicevdm'// MySQL database
  9. });
  10.  
  11. mysqlc.connect(function(e)
  12. {
  13. if(e) {
  14. console.log("ERROR: Brak połączenia z bazą danych !" + e);
  15. }
  16. else {
  17. console.log('Połączono z bazą danych !');
  18.  
  19. }
  20. });
  21.  
  22. mp.events.addCommand('register', (player) => {
  23.  
  24. console.log('Komenda /register wywołana.');
  25.  
  26. if(mysqlc.connect) {
  27. console.log('Połączenie z bazą stabilne.');
  28.  
  29. var playerName = player.name;
  30. console.log(playerName);
  31. var playerID = player.id;
  32. console.log(playerID);
  33.  
  34. var sql = "INSERT INTO users (id, name) VALUES ('10', 'Highway 37')";
  35. mysqlc.query(sql, function (e, result){
  36. if(e) throw e;
  37. console.log('Dane wysłane.');
  38. })
  39.  
  40. }
  41. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement