• SQL Query Problems
    17 replies, posted
I am having problem with the following query: [PHP] steamID = ply:GetNWString("SteamID") totalTags = sql.QueryValue("SELECT count(tags) FROM player_stats WHERE unique_id = '"..steamID.."'") totalDeaths = sql.QueryValue("SELECT count(deaths) FROM player_stats WHERE unique_id = '"..steamID.."'")[/PHP] It is just returning the value "False" is what shows up in my label... I have also tried: [PHP] steamID = ply:GetNWString("SteamID") totalTags = sql.QueryValue("SELECT tags FROM player_stats WHERE unique_id = '"..steamID.."'") totalDeaths = sql.QueryValue("SELECT deaths FROM player_stats WHERE unique_id = '"..steamID.."'")[/PHP] They both return "false" and I have no idea why!
[php] function TableCheck() if (sql.TableExists("player_stats")) then Msg("*****Table Already Exists - No Need To Create It Again!*****\n") else if (!sql.TableExists("player_stats")) then Msg("*****Table Not Found - Creating a New Table Now!*****\n") query = "CREATE TABLE player_stats ( unique_id varchar(255), tags int, deaths int )" result = sql.Query(query) end end end [/php]
Hum... Did you do this? [lua] function SetNWSteamID( ply ) ply:SetNWString("SteamID", ply:SteamID()) end hook.Add("PlayerInitialSpawn", "SetNWSteamID", SetNWSteamID) [/lua]
Yep
I still have yet to find a solution to this problem.
did you make something like : [lua]sql.Query( "INSERT INTO player_stats ('unique_id', 'tags', 'death', )VALUES ('"..SID.."', '0', '0')" )[/lua] at the playerinitial spawn ?
I sure did.
[b][url=http://wiki.garrysmod.com/?title=Player.SteamID]Player.SteamID [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b] is shared now. No need for the SetNWString.
Well thats very useful. Haha but I still can't seem to find a solution to this little problem...
Well just glancing over the thread you talk about using the sql query for a label. If you are setting the sql values serverside you won't be able to access them clientside.
I put a section to call these [lua]steamID = ply:GetNWString("SteamID") totalTags = sql.QueryValue("SELECT count(tags) FROM player_stats WHERE unique_id = '"..steamID.."'") totalDeaths = sql.QueryValue("SELECT count(deaths) FROM player_stats WHERE unique_id = '"..steamID.."'")[/lua] in cl_init.lua shouldn't that pull the values?
[QUOTE=Dizzymagoo;22675645]I put a section to call these [lua]steamID = ply:GetNWString("SteamID") totalTags = sql.QueryValue("SELECT count(tags) FROM player_stats WHERE unique_id = '"..steamID.."'") totalDeaths = sql.QueryValue("SELECT count(deaths) FROM player_stats WHERE unique_id = '"..steamID.."'")[/lua] in cl_init.lua shouldn't that pull the values?[/QUOTE] Not if you are setting them serverside, aka init.lua.
Hmmm... well how would I go about pulling these stats onto a form on the clientside?
Bump
[url=http://wiki.garrysmod.com/?title=Umsg]Usermesasges[/url].
You... are... dumb...
Sorry, you need to Log In to post a reply to this thread.