Jump to content

Problem with a sql query [FIXED]


Dunstark

Recommended Posts

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 by Guest
Link to comment

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...