Michcio Posted February 3, 2013 Posted February 3, 2013 Debug outputs: "ERROR: nowy_system\konta_s.lua:4: attempt to get length of local 'result' (a boolean value)" function zarejestruj (plr,cmd,login,haslo) if login ~= nil and haslo ~= nil then local result = exports.sql:query_assoc( "SELECT login FROM konta WHERE login = "..login ) if (#result == 0) then local insertid,e = exports.sql:query_insertid( "INSERT INTO konta ( kasa, score ) VALUES (" .. table.concat( { 5000, 0 }, ", " ) .. ")" ) if insertid then exports.sql:query_free( "UPDATE konta SET login = '"..login.."' WHERE ID = "..insertid ) exports.sql:query_free( "UPDATE konta SET haslo = '"..md5(haslo).."' WHERE ID = "..insertid ) outputChatBox( "Konto zarejestrowane. (ID: " .. insertid .. ")",plr,255,255,0 ) else outputDebugString( e ) outputChatBox( "Blad bazy MySQL.", player, 255, 0, 0 ) end else outputChatBox( "Taki login juz istnieje!",plr,255,255,0 ) end end end addCommandHandler("zarejestruj",zarejestruj)
Castillo Posted February 3, 2013 Posted February 3, 2013 Result is returning a boolean, but you are trying to get length of it, which is why it returns an error, you can't get length of a boolean.
Puma Posted February 3, 2013 Posted February 3, 2013 So, line 4 should be: if result and #result == 0 then Something else: your MySQL is wrong. login and haslo arguments are strings. If you put it in the query, you need to add ' ' around the string. In a MySQL query, all string-values must be between ' '. I guess login is an username, for example "Puma", so then it should be 'Puma' in the MySQL query and not Puma (without ' '). Numbers do not need ' '. So this: "SELECT login FROM konta WHERE login = "..login Should be this: "SELECT login FROM konta WHERE login = '"..login.."'"
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