..:D&G:.. Posted March 26, 2016 Posted March 26, 2016 PLEASE someone tell me what is wrong with this before I go nuts! function checkLoginCreditals(name, pass) local result = db:query( "SELECT * FROM users WHERE name ='"..name.."'") if result then if md5(pass) == tostring(result[1]['password']) then return true else return false end end return false end It outputs the password and username as it should, but from line 3 onwards it doesn't work.... I've used THE SAME THING, in another function and it works perfectly! function setPlayerDatas(player, accountName) local result = db:query("SELECT * FROM users WHERE name = '"..accountName.."'") if result then setData(player, "deaths", tonumber(result[1]['deaths'])) setData(player, "woodHarvested", tonumber(result[1]['woodHarvested'])) setData(player, "kills", tonumber(result[1]['kills'])) setData(player, "accountName", tostring(accountName)) end end addEvent("setPlayerDatas", true) addEventHandler("setPlayerDatas", getRootElement(), setPlayerDatas) So what the hell is wrong with the first function? -.-
Dimos7 Posted March 26, 2016 Posted March 26, 2016 i think it is like this db:query("SELECT * FROM users WHERE name=?", name)
..:D&G:.. Posted March 26, 2016 Author Posted March 26, 2016 I managed to find the problem, but I am so pissed that I can't figure out how to solve it :@ So if I do this: outputDebugString(""..userName.."WORD") it comes up as: INFO: Username WORD, now how do I remove the space at the end of the username so I have the username and 'WORD' joined together?
..:D&G:.. Posted March 26, 2016 Author Posted March 26, 2016 if it its like this write not have space I don't know why, I don't know how, but look:
ozulus Posted March 26, 2016 Posted March 26, 2016 If you still need help, here you go. outputDebugString(userName.."WORD") -- output --> INFO: Username WORD -- Use string.gsub to remove spaces, so it will be like that, local userName = string.gsub(userName, " ", "") outputDebugString(userName.."WORD") -- output --> INFO: UsernameWORD
..:D&G:.. Posted March 26, 2016 Author Posted March 26, 2016 If you still need help, here you go. outputDebugString(userName.."WORD") -- output --> INFO: Username WORD -- Use string.gsub to remove spaces, so it will be like that, local userName = string.gsub(userName, " ", "") outputDebugString(userName.."WORD") -- output --> INFO: UsernameWORD I managed to solve it. It was because I used guiCreateMemo which adds a space at the end regardless of what I am doing to the word. So I switched to guiCreateEdit and it works fine.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now