Dunstark Posted April 21, 2011 Share Posted April 21, 2011 (edited) Hello, I have a problem with a command I created. The syntax is as follow: "/setfaction Character_Name Faction_Id" addCommandHandler("setfaction", function (player, cmd, nom_cible, newfaction_id) local query = "UPDATE 'characters' SET 'faction_id'='"..tonumber(newfaction_id).."' WHERE name="nom_cible" ;" if (not mysql_query(MYSQL_serv,query)) then outputDebugString("Error executing the query: (" .. mysql_errno(MYSQL_serv) .. ") " .. mysql_error(MYSQL_serv),1) return false else outputDebugString(""..nom_cible.."a rejoint avec succès la faction "..newfaction_id.."",1) end end ) It gives me the following error: Error line 123(the line where the query is stored) attempt to call local 'nom_cible' (a string value) Thank you for your help Edited May 1, 2011 by Guest Link to comment
eAi Posted April 22, 2011 Share Posted April 22, 2011 You're missing .. either side of nom_cible. Link to comment
Dunstark Posted April 22, 2011 Author Share Posted April 22, 2011 Thank for your help eAi When I add the ".." at each side, it gives me the following error: "ERROR: mtarp\scripts\server\commands.lua:125: Error executing the query: (1064) 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 ''characters' SET 'faction_id'='1' WHERE name=Andrew_Fell' at line 1" Link to comment
Moderators Citizen Posted April 23, 2011 Moderators Share Posted April 23, 2011 Hi, Try to delete de ; at the end. Link to comment
Dunstark Posted April 24, 2011 Author Share Posted April 24, 2011 Hi Citizen, thanks for your help; sadly it gives me the same error. Link to comment
Bumbis Posted April 26, 2011 Share Posted April 26, 2011 Try this query - "UPDATE characters SET faction_id='"..tonumber(newfaction_id).."' WHERE name='"..nom_cible.."'" Link to comment
Dunstark Posted May 1, 2011 Author Share Posted May 1, 2011 Thank you or you help, it works perfectly 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