SQLite game database help

Hey guys, I’m new to SQL and I’m not quite sure what I’m doing wrong. I’m posting all of my sql functions in the code below. What I am trying to do is setup an atm that saves to sql instead of txt files (like it used to and I know this is inefficient and a pain to backup so I want sql)

Anyways, heres the code and thanks in advanced, probably a stupid problem.

[lua]
function atm_checktables()
if sql.TableExists(“atm”) then
ServerLog( "ATM Table Exists.
" )
else
local query = “CREATE TABLE atm ( pid INTEGER PRIMARY KEY AUTOINCREMENT, unique_id varchar(255), money INTEGER) )”
result = sql.Query(query)
ServerLog( "ATM: Creating Table…
" )
if sql.TableExists(“atm”) then
ServerLog( "ATM: Table created sucessfully.
" )
else
ServerLog( "ATM: Trouble creating the table!
" )
ServerLog( “ATM: " … sql.LastError( result )…”
" )
end
end
end

function atm_reloadtables()
if sql.TableExists(“atm”) then
local query = “DROP TABLE atm”
result = sql.Query(query)
end
atm_checktables()
end
hook.Add( “InitPostEntity”, “ATM_Load”,atm_reloadtables)

function saveData(ply)
local uid = ply:SteamID()
local save = ply:GetNWInt(“moneyBank”)
local query = “UPDATE atm SET money=’” … save … “’, WHERE unique_id=’” …uid… “’”
result = sql.Query(query)
end

function loadPlayer( ply )
local uid = ply:SteamID()
local query = “SELECT * FROM atm WHERE unique_id=’” … uid … “’”
result = sql.QueryValue(query)
local money = tonumber( result )

if money == nil then
	ply:SetNWInt("moneyBank", 0)
	sql.Query("INSERT INTO atm VALUES (NULL, '" ..uid.. "', 0)")
else
	ply:SetNWInt("moneyBank", money)
end

end
hook.Add( “PlayerInitialSpawn”, “loadPlayer”, loadPlayer )
[/lua]

Hello,

Not sure if there is any more problems than I have noticed as I have only had a brief look. Here are the ones I have spotted as follows:

  1. Where you first try to create your table your SQL Syntax is incorrect, it should be.

local query = "CREATE TABLE atm ( pid INTEGER PRIMARY KEY AUTO_INCREMENT, unique_id varchar(255), money INTEGER)"

  1. Where you try to update a users money you should be doing (comma has been removed just before the WHERE)

local query = "UPDATE atm SET money='" .. save .. "' WHERE unique_id='" ..uid.. "'"

Next time try to dump any line numbers if it says in console there is an error so we can assist you better.