Jump to content

Mysql Login


Recommended Posts

i make it finaly with some help the register version but now i get a new problem i cant log in :( 

here is my login server side script:

addEvent("loginReguest",true)
function loginReguest(player,username,password)
	local check = exports.mysql:_QuerySingle("SELECT * FROM users WHERE username = ? " ,username)
	if check then
		local checkPass = check.password
		if (checkPass == password) then
			logIn(player,getAccount(username),tostring(password))
			triggerClientEvent(player,"showHide", getRootElement())
			outputDebugString("User Logged In")
		end
	end
end
addEventHandler("loginReguest",getRootElement(), loginReguest)

there is my mysql script :

local connection = nil
addEventHandler("onResourceStart", resourceRoot,
function(resource)
	connection = dbConnect( "mysql", "dbname=mtalogin;host=localhost", "root", "", "share=1" )
	if connection then
		outputDebugString(getResourceName(resource) .. "Sqlite connection establised!" )
	else
		outputDebugString(getResourceName(resource) .. "Sqlite connection ERROR!")
		return false
	end
end
)


function _Query( ... )
	if connection then
		local query = dbQuery(connection, ... )
		local result = dbPoll(query, -1)
		return result
	else
		return false
	end
end


function _QuerySingle(str,...)
	if connection then
	local result = Query(str,...)
	if type(result) == 'table' then
		return result[1]
	end	
	else 
		return false
	end
end

function _Exec(str,...)
	if connection then
		local query = dbExec(connection,str,...)
		return query
	else
		return false
	end
end

and ther is my debug image :( mta-screen_2016-10-22_13-45-34.png

Link to comment

Come on man, please try to solve first the problems and when you see that you can't find a solution post it. Please.


function _QuerySingle(str,...)
	if connection then
	local result = _Query( ... ) --I'd check the parameters what you wanna send
	if type(result) == 'table' then
		return result[1]
	end	
	else 
		return false
	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...