MySQL Module Issues

I am getting the following error when I try to use MySQL:

Gamemode/gamemode/init.lua:77: attempt to index local ‘uid’ (a boolean value)

My lua:
[lua]–Lines 75 - 93

function steamcheck(name, pass, steam, ip)
local uid = db(steam)
if uid[1] and uid[1][2] then
local allowed = dba(steam,“2”)
if allowed[1] and allowed[1][2] then
return true
return {false, “The server is currently for admins only.”}
return {false, “You have been added to the database. Please reconnect to join the server.”}
local close = mysql.disconnect(db);
if close then end
hook.Add(“PlayerPasswordAuth”, “Example”, steamcheck)

– DB function
function db(steam)
local db = mysql.connect(‘HOST’, ‘USER’, ‘PASS’, ‘DB Name’)
return mysql.query(db, “SELECT * FROM rave1 WHERE steam = '” … steam … “’”);

Simply reading the error tells you the problem. It seems your db function is returning either true or (most probably) false, maybe because of a failed request? I don’t really know that library. :smile:

Actually it’s either that or uid[1] is a boolean value and you can’t index it. What should db return usually?

Anyway you should try using print() in several parts of your script to debug, it’s very helpful.

It worked up until earlier, and all I changed was the DB information. (changed to a better host, was using db4free


Ok, I created some test code and it causes the server to appear crashed for about 15 seconds then come back with nothing.

[lua]function sqlCheck(ply)
local db, error = mysql.connect(Connection Information goes here)
if (db == 0) then ply.ConCommand("say " … tostring(error) … "
") return end

print("connection opened - " .. db .. "!


test, isok, error = mysql.query(db, "SELECT * FROM rave1 WHERE steam = '" .. ply:SteamID() .. "'"); 
if (test) then  
	ply:ConCommand("say Yeah!")  
if (!isok) then  
	ply.ConCommand("say " .. tostring(error) .. "


local succ, error = mysql.disconnect(db)  
if (not succ) then  
	ply.ConCommand("say " .. error );  




Ok, obvious stupidity is obvious, fixed and testing again


Ok, so now its giving me the error (using the above):
Unknown MySQL server host ‘’ (11004)

Checking another url that I have here


Now the error is
Can’t connect to MySQL server on ‘’ (10065)

This is really confusing the hell outta me, because the SQL is accessed by my website fine

Your new server does not have remote access, ask your host if they can turn it on for you. Some hosts won’t do this though. It’s probably accessed by your website find because your database is probably local to the site, whereas a game server is not unless it’s a dedicated server box.

Does anyone know of a host that allows this? I have talked to 2 ( and and they both disallow this. allow it, not automatically but if you have a good enough reason they will open port 3306 does allow it, I host with them and get along fine.

Hmm. Will have to recheck with them (have an account on there expiring in about a month). There a bit expensive though, get cheaper for more through my game server host.