echoHU Posted November 24, 2018 Share 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 Link to comment Share on other sites More sharing options...
MrPancakers Posted November 24, 2018 Share Posted November 24, 2018 (edited) Ignore this I read your file structure wrong. Edited November 24, 2018 by MrPancakers 1 Link to comment Share on other sites More sharing options...
echoHU Posted November 26, 2018 Author Share 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..🙄 Link to comment Share on other sites More sharing options...
andreixd23 Posted November 26, 2018 Share Posted November 26, 2018 Connect: function(callback) do you ever call this function ? Otherwise handle will remain null. Link to comment Share on other sites More sharing options...
MrPancakers Posted November 27, 2018 Share 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. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now