Jump to content

Recommended Posts

 

The connection is okay but dbQuery and dbPoll first argument got nil. ( sorry for my bad english )

ERROR:

Spoiler

[2018-01-28 07:26:13] WARNING: mysql/server.lua:16: Bad argument @ 'dbQuery' [Expected db-connection at argument 1, got nil]
[2018-01-28 07:26:13] WARNING: mysql/server.lua:17: Bad argument @ 'dbPoll' [Expected db-query at argument 1, got boolean]
[2018-01-28 07:26:13] ERROR: felhasznalo/server.lua:8: attempt to call global 'mysql_num_rows' (a nil value)

 

MYSQL CONNECTION CODE:

Spoiler

 


addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), 
	function()
		mysql_kapcsolat = dbConnect("sqlite", "szerver.db")
		if mysql_kapcsolat then
			outputDebugString("MYSQL: A kapcsolat létrejött.")
			return true
		else
			outputDebugString("MYSQL: A kapcsolat megszakadt. Kérlek vedd fel a kapcsolatot a fejlesztővel.")
			return false
		end
	end
)

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

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

"felhasznalo" SCRIPT:

Spoiler

addCommandHandler("regisztralas", 
	function(player, command, jelszo)
	local nev = getPlayerName(player)	
	local ip = getPlayerIP(player)
	local serial = getPlayerSerial(player)
	
	local query_regisztralas = exports.mysql:_Query("SELECT felhasznalonev FROM felhasznalok WHERE felhasznalonev='" .. nev .. "'")
	if(mysql_num_rows(query_regisztralas) > 0) then
		outputChatBox("Már van ilyen felhasználó.", player)
	end
	
	exports.mysql:_Exec("insert into felhasznalok(felhasznalonev, jelszo, ip, serial) values(?, ?, ?, ?)", nev, jelszo, ip, serial)
	outputChatBox("Regisztráltál.", player)
	
	if jelszo == nil then outputChatBox("/regisztralas [jelszó]", player) 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...