• MySQL Issues (Using GM_Mysql)
    2 replies, posted
Hello, I have been having problems with my tables not being saved or ANYTHING for that matter... Here is the coding ( and the problem below it)[PHP]function Test.NewAccount(ply) local db, error = mysql.connect("*********", "********", "********", "********") if(db == 0) then Msg(error .. "\n") return end local steamid = ply:SteamID() local succ, error = mysql.query(db, "INSERT INTO test_accounts (steamid,test1,test2,test3,rank) VALUES(" .. steamid ..", 0, 0, 0, 0)"); if(succ) then PrintTable(succ) Msg("Account Created, 0 Characters At The Moment!\n" else print(tostring(error) .. "\n"); end mysql.disconnect(db) end function Test.Preload(ply) local db, error = mysql.connect("******", "*******", "******", "*******") if(db == 0) then Msg(error .. "\n") end local preload, checkexist = mysql.query(db, "SELECT * FROM liquidrp_accounts WHERE steamid='"..tostring(ply:SteamID()).."')"); if(checkexist == false) then Msg("Account doesn't exist\n") Test.NewAccount(ply) else PrintTable(preload) end mysql.disconnect(db) end[/PHP] The Current problem is, on initial spawn it calls the preload.... Recognizes there is no account, and class new account... And new account claims the message "Account Created... etc" But its not saving, because everytime I rejoin it goes through the same thing OVER and OVER and OVER. Could it be where I placed my DLL btw? I placed in the orangebox folder(before gmod, cuz it said the gmod/gmod first one, and didn't have that so just assumed) also both dlls needed in the lua/includes/modules are in the corect folder. Any Ideas? :3 Thanks in advance. ADDITIONAL INFO: I checked the tables, and nothing is being created. [editline]12:21AM[/editline] [QUOTE=dorfy;20388630]Hello, I have been having problems with my tables not being saved or ANYTHING for that matter... Here is the coding ( and the problem below it)[PHP]function Test.NewAccount(ply) local db, error = mysql.connect("*********", "********", "********", "********") if(db == 0) then Msg(error .. "\n") return end local steamid = ply:SteamID() local succ, error = mysql.query(db, "INSERT INTO test_accounts (steamid,test1,test2,test3,rank) VALUES(" .. steamid ..", 0, 0, 0, 0)"); if(succ) then PrintTable(succ) Msg("Account Created, 0 Characters At The Moment!\n" else print(tostring(error) .. "\n"); end mysql.disconnect(db) end function Test.Preload(ply) local db, error = mysql.connect("******", "*******", "******", "*******") if(db == 0) then Msg(error .. "\n") end local preload, checkexist = mysql.query(db, "SELECT * FROM liquidrp_accounts WHERE steamid='"..tostring(ply:SteamID()).."')"); if(checkexist == false) then Msg("Account doesn't exist\n") Test.NewAccount(ply) else PrintTable(preload) end mysql.disconnect(db) end[/PHP] The Current problem is, on initial spawn it calls the preload.... Recognizes there is no account, and class new account... And new account claims the message "Account Created... etc" But its not saving, because everytime I rejoin it goes through the same thing OVER and OVER and OVER. Could it be where I placed my DLL btw? I placed in the orangebox folder(before gmod, cuz it said the gmod/gmod first one, and didn't have that so just assumed) also both dlls needed in the lua/includes/modules are in the corect folder. Any Ideas? :3 Thanks in advance. ADDITIONAL INFO: I checked the tables, and nothing is being created.[/QUOTE] EDIT: i think the problem was I forgot the ' '?
in preload it should be if( #preload >= 1 ) then PrintTable(preload) else Test.NewAccount(ply) end
[QUOTE=Averice;20388860]in preload it should be if( #preload >= 1 ) then PrintTable(preload) else Test.NewAccount(ply) end[/QUOTE] Fixed, thanks also forgot the single quotations marks :P [editline]03:07AM[/editline] [QUOTE=Averice;20388860]in preload it should be if( #preload >= 1 ) then PrintTable(preload) else Test.NewAccount(ply) end[/QUOTE] You lie! because it still goes to new account everytime (however it does actually save into the DB now)
Sorry, you need to Log In to post a reply to this thread.