Check database if user exists

So i’m trying to create a simple check to see if a user exists via steam id in a database, I made a simple lua file and stuck it in autorun/server and it doesn’t seem to work, I can’t find any errors related to the file and I have no clue if it even ran, I never really made anything from scratch just edited a lot of game modes that were already there so if I’m doing something wrong please let me know.

I don’t get a chat message at all when I use the code below and I followed an old tutorial on using mysql

[lua]
require (“mysqloo”)

local DATABASE_HOST = “topsecre” // database host (can be an ip)
local DATABASE_PORT = 3306 // port to the database, you probably wont need to change this unless you get told to
local DATABASE_NAME = “vip” // name of the database
local DATABASE_USERNAME = “topsecret” // username which you use to access it
local DATABASE_PASSWORD = “topsecret” // password of the username

local function checkQuery(query)
local RowReturn = query:getData()
if RowReturn[0] ~= nil then
return true
else
return false
end
end

local function CheckDonorOnSpawn(ply)
databaseObject = mysqloo.connect(DATABASE_HOST, DATABASE_USERNAME, DATABASE_PASSWORD, DATABASE_NAME, DATABASE_PORT)
databaseObject.onConnected = function() print(“Database linked!”) end
databaseObject.onConnectionFailed = function() print(“Failed to connect to the database.”) end
databaseObject:connect()
local DonorQuery = databaseObject:query(“SELECT * FROM vip_gmod WHERE steamid = '” … ply:SteamID() … “’”);
DonorQuery.onSuccess = function(q)
if checkQuery(q) then
ply:SetUserGroup( “donor” )
ply:ChatPrint(“Welcome to the server donor!”)
else
ply:ChatPrint(“Welcome to the server!”)
end
end
return true
end
hook.Add(“PlayerInitialSpawn”, “CheckDonorOnSpawn”, CheckDonorOnSpawn)
[/lua]

MySQL OO requires a bit… But, try using string.rep( “*”, 500 ) in your print statement to print 500 *s. Then you’ll be able to easily find it.

Also, you’re better off connecting to the database on Initialize, not InitialSpawn; Load the player data via query on Initial spawn, or similar hook.

Here are some MySQL tutorials ( the basics / setting it up with fallbacks, without fallbacks, call a hook so if the server didn’t connect properly you can have it do something, etc )

https://dl.dropboxusercontent.com/u/26074909/tutoring/database/_connecting_with_mysqloo.lua.html

https://dl.dropboxusercontent.com/u/26074909/tutoring/database/_connecting_with_tmysql.lua.html

https://dl.dropboxusercontent.com/u/26074909/tutoring/database/_connecting_with_fallbacks_in_place.lua.html