Hera Posted May 16, 2019 Share Posted May 16, 2019 function MysqlName(sqlid, cb) { iHandle.mysql.handle.query("SELECT `Username` FROM `accounts` WHERE `UserID`= ?", [sqlid], function (err, rows, fields) { if (err) throw err; cb(rows[0].Username); }); } var qwf = null; MysqlName(19, function (name) { qwf = name; console.log("returning name: " + name) // return Firstname_Lastname (its ture) } ); console.log(qwf); // RESULT NULL I did a function to pull the user name from the database. I can't assign it to global value. A very interesting mistake. How can I solve this? 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