• Need just a little help with MySQL!
    4 replies, posted
[lua]local query3 = db:query("INSERT INTO players(ID, money) VALUES ('" .. v:SteamID() .. "', " .. v:GetNWInt("Cash") .. ")")[/lua] This creates a new duplicate row, but how can you update the old one? Thanks, Roope
[url]http://www.w3schools.com/sql/sql_update.asp[/url]
Thanks, new problem. [lua]local query3 = db:query("UPDATE players SET money='" .. v:GetNWInt("Cash") .. "' " .. "WHERE ID='" .. v:SteamID() .. "'")[/lua] If someone has the same amount of money that someone already has on the mysql(2500 in this case) and this tries to save it, it says [lua]Duplicate entry '2500' for key 'PRIMARY'[/lua] and doesn't save it.
[QUOTE=RoopeFI;40322826]Thanks, new problem. [lua]local query3 = db:query("UPDATE players SET money='" .. v:GetNWInt("Cash") .. "' " .. "WHERE ID='" .. v:SteamID() .. "'")[/lua] If someone has the same amount of money that someone already has on the mysql(2500 in this case) and this tries to save it, it says [lua]Duplicate entry '2500' for key 'PRIMARY'[/lua] and doesn't save it.[/QUOTE] For some reason you have made a column primary which shouldn't be. Make the column `ID` primary and it should work.
Now I can't add Auto Increment to ID! Wait do you even need that?
Sorry, you need to Log In to post a reply to this thread.