99isme Posted April 3, 2021 Share Posted April 3, 2021 so I got this error when using UDClogging of Noki local stdLogged = 0 local db = exports.UDCsql:getConnection() function adminLog() end function stdLog(plr, type1, action, type2) if (not plr) or (not type1) or (not action) then return nil end if (plr:getType() ~= "player") or (type(type1) ~= "string") or (type(action) ~= "string") then return false end if (not type2) then type2 = "N/A" end end function adminLog(admin, log_) local t = getRealTime().timestamp db:exec("INSERT INTO `adminlog` (`name`, `log_`, `datum`) VALUES (?, ?, ?)", admin, log_, t ) end function new(plr, type1, action, type2) if (not plr or not type1 or not action) then return nil end if (type(type1) ~= "string" or type(action) ~= "string") then return false end if (not type2) then type2 = "N/A" end local name local accname local serial if (plr and isElement(plr) and plr.type == "player") then if (exports.UDCaccounts:isPlayerLoggedIn(plr)) then accname = plr.account.name else accname = "N/A" end name = plr.name serial = plr.serial else name = tostring(plr) accname = "N/A" serial = "N/A" end dbExec(db, "INSERT INTO 'logging' SET name= 0, account= ?, type= ?, type2= ?, tick= ?, action= ?, serial= ?", name, accname, type1, type2, getRealTime{}.timestamp, action, serial ) stdLogged = stdLogged + 1 return true end function outputTotal(reset) if stdLogged ~= 0 then outputDebugString("[UDClogging] Total standard logs inserted in the past 5 minutes: "..stdLogged) end if (reset) then stdLogged = 0 end end setTimer(outputTotal, 60000 * 5, 0, true) addCommandHandler("logged", outputTotal) ------------------- -- Some stuff we need to log ------------------- function logConnections() -- The account will be guest, so we don't need to worry about the query not being successful new(source, "join", "Joined server", source.ip) end addEventHandler("onPlayerJoin", root, logConnections) function logDisconnections(quitType) new(source, "quit", tostring(quitType), source.ip) end addEventHandler("onPlayerQuit", root, logDisconnections) --File end Link to comment
Moderators Patrick Posted April 4, 2021 Moderators Share Posted April 4, 2021 You pass 7 args to dbExec, but you have only 6 questionmarks in query string. And you have to use ` instead of ' around table/column names. INSERT INTO `logging` SET name=?, account= ?, type= ?, type2= ?, tick= ?, action= ?, serial= ? Link to comment
99isme Posted April 4, 2021 Author Share Posted April 4, 2021 Can you give me an example? Link to comment
Tekken Posted April 4, 2021 Share Posted April 4, 2021 (edited) 1 hour ago, 99isme said: Can you give me an example? Quote INSERT INTO `logging` SET name=?, account= ?, type= ?, type2= ?, tick= ?, action= ?, serial= ? Your's is INSERT INTO `logging` SET name= 0, account= ?, type= ?, type2= ?, tick= ?, action= ?, serial= ? Notice the 0 for name where should be ? Edited April 4, 2021 by Tekken - Link to comment
99isme Posted April 4, 2021 Author Share Posted April 4, 2021 Already tested it and it didn't work. 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