• tmysql Guide?
    6 replies, posted
Hello all, Trying to find any information regarding tmysql. I know there is the guide ([url]https://facepunch.com/showthread.php?t=1442438[/url]) but I am struggling to get it working and can't find any reference to it anywhere. I have the following so far in my init.lua file [CODE]local Database, error = tmysql.Connect( "185.38.XXX.XXX", "gmXXX", "XXXXX", "gm_main", 3306, nil, CLIENT_MULTI_STATEMENTS ) [/CODE] - X in the blanking that user and pass. Error I am receiving is as follows. [CODE][ERROR] gamemode/player.lua:5: attempt to index global 'tmysql' (a nil value) 1. unknown - gamemode/player.lua:5[/CODE] The query that needs to run is simple enough and just pulls player information from a table, query as follows. [CODE]tmysql.query("SELECT Money,Class,Classes,Skills FROM fw_playerdata WHERE SteamID=\'"..steamid.."\'", function(res,stat,err) if err ~= 0 or (not IsValid(pl)) then return end[/CODE] Starting to get to grips with the Lua but this my squirrel is not working out for me. All help appreciated :)
Add: [lua] require("tmysql4") [/lua] at the top of your file.
Ok so I have added the require and now getting the following error? [CODE][ERROR] gamemodes/fortwars/gamemode/player.lua:5: attempt to call field 'query' (a nil value) 1. unknown - gamemodes/fortwars/gamemode/player.lua:5[/CODE] Is the code correct that I posted above? I am following the instructions in the guide :S
Do [lua] Database:Query(str) [/lua]
Doesn't like that either :S [CODE][ERROR] gamemodes/fortwars/gamemode/player.lua:11: attempt to index local 'Database' (a boolean value) 1. unknown - gamemodes/fortwars/gamemode/player.lua:11[/CODE]
[QUOTE=.0mega;50672692]Doesn't like that either :S [CODE][ERROR] gamemodes/fortwars/gamemode/player.lua:11: attempt to index local 'Database' (a boolean value) 1. unknown - gamemodes/fortwars/gamemode/player.lua:11[/CODE][/QUOTE] First result is a boolean telling you if it was successful in connecting, second is the database object
Thanks for that BigDogMat! All sorted and now linking to the database.
Sorry, you need to Log In to post a reply to this thread.