NickScripter Posted September 18, 2019 Posted September 18, 2019 (edited) I'm making a create faction command, but it return's WARNING into console. (example of the command that should work but returns error/criarfaccao 2 1 Test) "dbPoll failed; You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'groups SET Name='Test', balance='0', type1='2', type2='1'' at line 1" I tryed everything to fix it but without success. Any idea of what is wrong? (#Line 1) local connection = exports.sas_mysql:getConnection() Server-side function createGroup(playerSource, commandName, typ1, typ2, ...) if getElementData(playerSource,"adminlevel") >= 8 then if typ1 and typ2 and ... then typ1 = tonumber(typ1) typ2 = tonumber(typ2) groupName = table.concat({...}, " ") local theTeam = createTeam(tostring(groupName)) if theTeam then local query, _, id = dbPoll ( dbQuery( connection, "INSERT INTO groups SET Name=?, balance='0', type1='?', type2='?'", groupName, typ1, typ2), -1 ) if query then outputChatBox("#7cc576[TLRP V2 - Grupo]: #4aabd0"..groupName.." #fffffffacção criada com sucesso! #7cc576(ID: ".. id .. " - Tipo 1: ".. typ1 .." - Tipo 2: ".. typ2 ..")", playerSource, 124, 197, 118, true) else outputChatBox("#7cc576[TLRP V2 - erro]: Falha na criação SQL.", playerSource, 255, 0, 0,true) end else outputChatBox("#7cc576[TLRP V2 - erro]: Este grupo já existe. #4aabd0(" .. tostring(groupName) .. ")", playerSource, 255, 0, 0,true) end else outputChatBox("#7cc576[TLRP V2 - Uso]: #ffffff/" .. commandName .. " [Tipo 1] [Tipo 2] [Nome]", playerSource, 124, 197, 118, true) outputChatBox("#7cc576[Tipo 1]: #ffffffGang/Mafia = 2, Outro tipo = 1", playerSource, 124, 197, 118, true) outputChatBox("#7cc576[Tipo 2]: #ffffffPolicial = 1, Bombeiro = 2, SAMU = 3, Conselho = 4, Mafia = 5, Gang = 6, Organização = 7", playerSource, 124, 197, 118, true) end end end addCommandHandler("criarfaccao", createGroup) Edited September 18, 2019 by Nickqq
Moderators IIYAMA Posted September 18, 2019 Moderators Posted September 18, 2019 (edited) 21 minutes ago, Nickqq said: I tryed everything to fix it but without success. Any idea of what is wrong? Incorrect MySQL syntax, see here an insert example. https://www.tutorialspoint.com/mysql/mysql-insert-query.htm SET is afaik for variables. Edited September 18, 2019 by IIYAMA Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
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