echoHU 0 Posted November 24, 2018 (edited) Hello! I made this resource, and when i enter any information in game the console says this: C:\Users\varad\Desktop\PleasantRoleplay\packages\PleasantRoleplay\user-system\Login.js:11: TypeError: Cannot read property 'query' of null db.Handle.query("SELECT * FROM accounts WHERE username = ?", username, function(e, result) { Login.js: var db = require('../mysql/Connection'); mp.events.add('playerJoin', player => { player.call('loginShowPanel'); let alpha = player.alpha; player.alpha = 0; }); mp.events.add('loginSendInformation', (player, username, password) => { db.Handle.query("SELECT * FROM accounts WHERE username = ?", username, function(e, result) { if ( result.length ) { player.call('loginClosePanel'); let alpha = player.alpha; player.alpha = 255; } else player.outputChatBox("<b style='color: red'>This Username doesn't exist!</b>"); }); }); Connection.js: var mysql = require('mysql'); module.exports = { Handle: null, Connect: function(callback) { this.Handle = mysql.createConnection({ host : 'localhost', user : 'root', password : '', database : 'pleasantroleplay' }); this.Handle.connect(function(e) { if ( !e ) { callback(); } else console.log ("DATABASE ERROR" + e); }); } }; Index.js: require('./mysql/Connection'); require('./user-system/Login.js'); I have added Mysql module through npm. Edited November 24, 2018 by echoHU Share this post Link to post Share on other sites
MrPancakers 109 Posted November 24, 2018 (edited) Ignore this I read your file structure wrong. Edited November 24, 2018 by MrPancakers 1 Share this post Link to post Share on other sites
echoHU 0 Posted November 26, 2018 On 11/24/2018 at 11:26 PM, MrPancakers said: Ignore this I read your file structure wrong. I am here to learn and get some help..🙄 Share this post Link to post Share on other sites
andreixd23 0 Posted November 26, 2018 Connect: function(callback) do you ever call this function ? Otherwise handle will remain null. Share this post Link to post Share on other sites
MrPancakers 109 Posted November 27, 2018 14 hours ago, echoHU said: I am here to learn and get some help..🙄 I wasn't talking to you, I was saying to ignore my message, I had edited it because I read your question wrong. I can't delete replies. Share this post Link to post Share on other sites