Search code examples
mysqlluagarrys-mod

Getting error on a script


I created a script for the game Garry's Mod, but once is loaded on some servers, it gets the next error:

[ERROR] addons/ulib-master/lua/ulib/shared/hook.lua:110: addons/applysystem/lua/applysystem/init.lua:13: bad argument #1 to 'pairs' (table expected, got nil) fn - [C]:-1 unknown - addons/ulib-master/lua/ulib/shared/hook.lua:110

How can i fix it? this is the line 13:

for _, row in pairs(results[1].data) do

If needed, theres the entire function where the error is created:

db:Query("SELECT * FROM "..ApplySystem.MySQL.TableName.." WHERE delivered=0 AND status='Accepted.'", function(results)

        for _, row in pairs(results[1].data) do

            local steamid64 = row.steamid
            if steamid64 != "" or steamid64 != nil then

                local TransfSteamID = util.SteamIDFrom64(steamid64)
                RunConsoleCommand("ulx","adduserid",TransfSteamID,ApplySystem.MySQL.DefaultRank)
                db:Query("UPDATE "..ApplySystem.MySQL.TableName.." SET delivered=1 WHERE steamid='"..row.steamid.."'  ")
            end
        end

end)

Solution

  • Fixed, thanks guys, it was because i were trying to retrieve nil values.