Jump to content

dbPoll failed; no database selected


Quebec

Recommended Posts

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...