PauloCascus Posted August 7, 2014 Share Posted August 7, 2014 Hello guys again and again, I have the problem with SQL couze i have not enough knowledge about this: syntax error here is mine lua and SQL it is function to create your character: i don't know all paths are right or not but i have got error with syntax oly in dbExec( connection, "INSERT INTO ....... Some "pro" can to check code and say to me there are all right or i've did mistakes Becouze idk, SQL is hard to me addEventHandler("onResourceStart", resourceRoot, function () connection = dbConnect ("sqlite", "character.db" ) if connection then dbExec ( connection, "CREATE TABLE IF NOT EXISTS character ( account TEXT, heroname TEXT, herolastname TEXT, heroage INT, herocountry TEXT, herolang TEXT) " ) outputDebugString ( "Successfully connected to character database" ) else outputDebugString ( "Failed to connect to character database" ) end end ) function createHero(heroname,herolastname, heroage, herocountry, herolang) if not (heroname == "") then if not (herolastname == "") then if not heroname:find("%W") then if not (heroage == "") then if not (herocountry == "") then if not (herolang == "") then local account = getPlayerAccount(source) local accountname = getAccountName(account) local herona = dbQuery( connection, "SELECT * FROM character ( heroname=?") local heroln = dbQuery( connection, "SELECT * FROM character ( herolastname=?") if not (heroname == herona) and not ( herolastname == heroln ) then dbExec( connection,"INSERT INTO character ( account=?, heroname=?, herolastname=?, heroage=?, herocountry=?, herolang=?", accountname, heroname, herolastname, heroage, herocountry, herolang) triggerClientEvent(source,"changeMessage",getRootElement(),"2","Character seccessfully created","green") else triggerClientEvent(source,"changeMessage",getRootElement(),"2","This name already taken", "red") triggerClientEvent(source,"changeMessage",getRootElement(),"4","", "red") end else triggerClientEvent(source,"changeMessage",getRootElement(),"2","Please enter your language", "red") triggerClientEvent(source,"changeMessage",getRootElement(),"4","", "red") end else triggerClientEvent(source,"changeMessage",getRootElement(),"2","Please enter your country", "red") triggerClientEvent(source,"changeMessage",getRootElement(),"4","", "red") end else triggerClientEvent(source,"changeMessage",getRootElement(),"2","Please enter your birthday date", "red") triggerClientEvent(source,"changeMessage",getRootElement(),"4","", "red") end else triggerClientEvent(source,"changeMessage", getRootElement(), "2","Your name has invalid characters", "red") end else triggerClientEvent(source,"changeMessage", getRootElement(), "2","Please enter your last name", "red") end else triggerClientEvent(source,"changeMessage", getRootElement(), "2","Please enter your name", "red") end end addEvent("createHero",true) addEventHandler("createHero",getRootElement(),createHero) Link to comment
Anubhav Posted August 7, 2014 Share Posted August 7, 2014 function createHero(heroname,herolastname, heroage, herocountry, herolang) if not (heroname == "") then if not (herolastname == "") then if not heroname:find("%W") then if not (heroage == "") then if not (herocountry == "") then if not (herolang == "") then local account = getPlayerAccount(source) local accountname = getAccountName(account) local herona = dbQuery( connection, "SELECT heroname FROM character") local heroln = dbQuery( connection, "SELECT herolastname FROM character") local heroInA = dbPoll(heroIn, -1) local heronaA = dbPoll(herone, -1) if not (heroname == heronaA) and not ( herolastname == heroInA ) then dbExec( connection,"INSERT INTO character VALUES(?, ?, ?, ?, ?, ?)", accountname, heroname, herolastname, heroage, herocountry, herolang) triggerClientEvent(source,"changeMessage",getRootElement(),"2","Character seccessfully created","green") else triggerClientEvent(source,"changeMessage",getRootElement(),"2","This name already taken", "red") triggerClientEvent(source,"changeMessage",getRootElement(),"4","", "red") end else triggerClientEvent(source,"changeMessage",getRootElement(),"2","Please enter your language", "red") triggerClientEvent(source,"changeMessage",getRootElement(),"4","", "red") end else triggerClientEvent(source,"changeMessage",getRootElement(),"2","Please enter your country", "red") triggerClientEvent(source,"changeMessage",getRootElement(),"4","", "red") end else triggerClientEvent(source,"changeMessage",getRootElement(),"2","Please enter your birthday date", "red") triggerClientEvent(source,"changeMessage",getRootElement(),"4","", "red") end else triggerClientEvent(source,"changeMessage", getRootElement(), "2","Your name has invalid characters", "red") end else triggerClientEvent(source,"changeMessage", getRootElement(), "2","Please enter your last name", "red") end else triggerClientEvent(source,"changeMessage", getRootElement(), "2","Please enter your name", "red") end end addEvent("createHero",true) addEventHandler("createHero",getRootElement(),createHero) Link to comment
PauloCascus Posted August 8, 2014 Author Share Posted August 8, 2014 function createHero(heroname,herolastname, heroage, herocountry, herolang) if not (heroname == "") then if not (herolastname == "") then if not heroname:find("%W") then if not (heroage == "") then if not (herocountry == "") then if not (herolang == "") then local account = getPlayerAccount(source) local accountname = getAccountName(account) local herona = dbQuery( connection, "SELECT heroname FROM character") local heroln = dbQuery( connection, "SELECT herolastname FROM character") local heroInA = dbPoll(heroIn, -1) local heronaA = dbPoll(herone, -1) if not (heroname == heronaA) and not ( herolastname == heroInA ) then dbExec( connection,"INSERT INTO character VALUES(?, ?, ?, ?, ?, ?)", accountname, heroname, herolastname, heroage, herocountry, herolang) triggerClientEvent(source,"changeMessage",getRootElement(),"2","Character seccessfully created","green") else triggerClientEvent(source,"changeMessage",getRootElement(),"2","This name already taken", "red") triggerClientEvent(source,"changeMessage",getRootElement(),"4","", "red") end else triggerClientEvent(source,"changeMessage",getRootElement(),"2","Please enter your language", "red") triggerClientEvent(source,"changeMessage",getRootElement(),"4","", "red") end else triggerClientEvent(source,"changeMessage",getRootElement(),"2","Please enter your country", "red") triggerClientEvent(source,"changeMessage",getRootElement(),"4","", "red") end else triggerClientEvent(source,"changeMessage",getRootElement(),"2","Please enter your birthday date", "red") triggerClientEvent(source,"changeMessage",getRootElement(),"4","", "red") end else triggerClientEvent(source,"changeMessage", getRootElement(), "2","Your name has invalid characters", "red") end else triggerClientEvent(source,"changeMessage", getRootElement(), "2","Please enter your last name", "red") end else triggerClientEvent(source,"changeMessage", getRootElement(), "2","Please enter your name", "red") end end addEvent("createHero",true) addEventHandler("createHero",getRootElement(),createHero) thanks Link to comment
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