tmysql lua, not returning anything

[lua]require(“tmysql”)

tmysql.initialize(“", "”, “", "”, 3306)

function LoadStuff()
–local strSteamID = string.Replace(self:SteamID(), “:”, “!”)
local strSteamID = 0018691624
if strSteamID != “STEAM_ID_PENDING” then
tmysql.query(“SELECT items FROM inventory WHERE steamid=’”…strSteamID…"’", loadedstuff)
end
end
concommand.Add( “sqltest”, LoadStuff )

function loadedstuff(res)
print(res)
PrintTable( res )
end[/lua]

Ok so I have this code and I execute it and it does not to the



PrintTable( res )


However it does work as it does do



print(res)


The database it working there is data there so why is it not printing the table. I’m using tmysql3 btw.

I’ve hatched out the database login details for obvious reasons.

Since everything appears to be correct, try changing your callback function to

[lua]
function loadedstuff(res, stat, err)
print(stat)
print(err)
print(res)
PrintTable( res )
end[/lua]

to see if you’re getting any errors with the sql.



nil
nil
table: 34144038


Is printed. Does that mean a connection issue ?

The second print, err, should be 0, I’m not sure what’s going on.

just an update, I have fixed this problem through trial and error and frustration. The issue line was
[lua]
tmysql.query(“SELECT items FROM inventory WHERE steamid=’”…strSteamID…"’", loadedstuff)
[/lua]

which should have been like:

[lua]
tmysql.query("SELECT items FROM inventory WHERE steamid = " …strSteamID, loadedstuff)
[/lua]

It appears the way tmysql takes the arguments that it didn’t like the end bit. So if anyone else gets this issue there is the fix!

Thats perfectly normal sql behaviour; if you have a where condition and you are comparing a string, use quotes.