• sql.Query is not responding/working.
    2 replies, posted
So for some odd reason the following code does not work. The function calls all the way to the sql query, after the query is ran I go to check my table and no values have changed. All of the v.Val's and v.Name's return a "Correct" value. Also, I'm not sure why but these functions only seem to work with integers rather then strings. [b]The save function that I've made.[/b] [lua] function META:SaveValues() ply = self local SteamID = ply:SteamID() local exsists = sql.QueryValue("SELECT SID from TTCRP_PlyData WHERE SID = '"..SteamID.."'") if(exsists) then Save = {} Save[1] = {Name = "RealName", Val = ply:GetName()} Save[2] = {Name = "RPName", Val = ply:GetNWString("RPName")} Save[3] = {Name = "Money", Val = ply:GetNWInt("Money")} Save[4] = {Name = "PhysDesc", Val = ply:GetNWString("PhysDesc")} print("Save") for k,v in pairs(Save) do ply:SetSql(v.Name,v.Val) end end end [/lua] [b]The SetSQL function that I've made.[/b] [i]Example Input: ply:SetSql("RPName","Al Fraydo") --This would set a RP name to Al Fraydo.[/i] [lua] function META:SetSql(arg,arg2) ply = self local SteamID = ply:SteamID() if(arg == nil) then return false else sql.Query("UPDATE TTCRP_PlyData SET "..arg.." = '"..arg2.."' WHERE SID = '"..SteamID.."'") print(sql.LastError()) end end [/lua]
I find "SELECT lol FROM hai WHERE lol = "..sql.SQLStr(SteamID)..";" much nicer sql.LastError() returns any errors in your sql queries, i find it highly useful
Thank you, it appears to work now with some much needed efficiency.
Sorry, you need to Log In to post a reply to this thread.