Normand Posted January 28, 2018 Posted January 28, 2018 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 )
WorthlessCynomys Posted January 28, 2018 Posted January 28, 2018 Go to WIKI and read what arguments dbConnect has. There are a few example lines too, including a mysql connection. You can copy paste it and edit the line so it works for you.
Normand Posted January 28, 2018 Author Posted January 28, 2018 mysql_kapcsolat = dbConnect("sqlite", "szerver.db", _, _, "share=0", "batch=0", "autoreconnect=1", "log=1")
NanoBob Posted January 30, 2018 Posted January 30, 2018 Is your database actually mySQL or SQLLite? Because you state mysql both in your code and topic title, but your dbConnect call is for a SQLLite database. 1
NeXuS™ Posted January 30, 2018 Posted January 30, 2018 Line nr. 16 local query = dbQuery(myqsl_kapcsolat, ...) to local query = dbQuery(mysql_kapcsolat, ...)
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