Quebec Posted June 2, 2021 Share Posted June 2, 2021 I'm trying to make a login system but I keep getting this error: WARNING: login-panel\login_panel_s.lua:9: dbPoll failed; No database selected ERROR: login-panel\login_panel_s.lua:10: attempt to get length of local 'result' (a boolean value) This is the code: local db = exports.dbconnection:getConnection() addEvent('login:registerAccount', true) addEventHandler('login:registerAccount', root, function(thePlayer, username, password, email) if not username or not password or not email then return false end local queryCheck = dbQuery(db, "SELECT * FROM `accounts` WHERE `username` = '" .. username .. "'") local result = dbPoll(queryCheck, -1) if #result > 0 then return outputChatBox("Acest username exista deja!") end local mtaserial = getPlayerSerial(thePlayer) local playerIP = getPlayerIP(thePlayer) local hash = passwordHash(password, "bcrypt", {}) if hash then dbExec(db, "INSERT INTO `accounts` (`username`, `password`, `ip`, `mtaserial`, `email`) VALUES (?, ?, ?, ?, ?)", username, hash, ip, mtaserial, email) outputChatBox("Contul a fost creat cu succes", thePlayer) end end) Link to comment
Scripting Moderators srslyyyy Posted June 2, 2021 Scripting Moderators Share Posted June 2, 2021 Are you sure that db returns valid database connection? Tip in custom events: Use client variable instead of passing player to server - see https://wiki.multitheftauto.com/wiki/Script_security 1 Link to comment
Quebec Posted June 2, 2021 Author Share Posted June 2, 2021 8 minutes ago, srslyyyy said: Are you sure that db returns valid database connection? Tip in custom events: Use client variable instead of passing player to server - see https://wiki.multitheftauto.com/wiki/Script_security Actually I think this could be an issue, I'll check when I get back home if everything is alright in the mysql connection Link to comment
Quebec Posted June 2, 2021 Author Share Posted June 2, 2021 3 hours ago, srslyyyy said: Are you sure that db returns valid database connection? Tip in custom events: Use client variable instead of passing player to server - see https://wiki.multitheftauto.com/wiki/Script_security I checked the database connection code again and I found the error, dbConnect had some faulty arguments. Problem got fixed, thank you! Link to comment
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