Save to MySQL on disconnect..

hey all,

i’m seriously having a hard time getting players data saved to a mysql database on disconnect.
i’m pretty sure the function is called, i had some print()'s in there before and that worked fine.
so i took the query i use to get the players data when they join and when their new but converted the “INSERT INTO” Players to a “UPDATE” one.
its also not outputting an error or anything.

this is the bit of code i’m trying to run



function fPlayerDisconnect( ply )
    local cash = ply:GetMoney() 
    -- meta:GetMoney(): function is inside shared.lua and retrieves a NetworkedInt (works without problems in the HUD)

    local saveQuery = databaseObject:query("SELECT * FROM Players WHERE ID = '" .. ply:SteamID() .. "'")
    saveQuery.onSuccess = function(q)
        if not checkQuery(q) then
            local saveQuery2 = databaseObject:query("UPDATE Players SET Money='".. cash .."' WHERE ID='".. ply:SteamID() .."'")
            saveQuery2.onSuccess = function(q) print("[X] Saved Player: "..ply:GetName()) end
            saveQuery2.onError = function(q,e) print("
[X] MySQL Error: "..e.."
While Executing: "..q.."
") end
            saveQuery2:start()    
        end
    end
    saveQuery.onError = function(q,e) print("
[X] MySQL Error: "..e.."
While Executing: "..q.."
") end
    saveQuery:start()
end
hook.Add( "PlayerDisconnected", "playerdisconnected", fPlayerDisconnect )


Could someone point me out where i went wrong?

Thanks.

well, take a look into the SQL Library instead of those metatable functions http://wiki.garrysmod.com/?title=Sql

EDIT: or use the mysqloo module, or some other MySQL module

Oh forgot to mention that, i’m using the mysqloo module. sorry about that.

edit: found out what i did wrong:



if **not** checkQuery(q) then


the not isn’t supposed to be there…