Alright people I am having some issues understanding the syntax for query_sql
what I am trying to achieve is to delete the character through a script, and the following are the ways I have tried doing it so far.
any help is appriciated and of course I will pay back to the community with my knowledge!
- script game_mechanics -1,{
OnPCDieEvent:
set #id,getcharid(0); //get their character ID
announce strcharinfo(0) +" was killed by "+ rid2name(killerrid),0xFFFF00;
atcommand "@kick "+#id;
//ways I have tried so far
//query_sql("DELETE FROM char WHERE char_id='"+escape_sql(#id)+"'");
//query_sql("DELETE FROM char WHERE char_id='"+getcharid(0)+"'");
query_sql("DELETE FROM 'char' WHERE 'char_id' = '"+getcharid(0)+"' ");
end;
//query_sql from other scripts to help me.
//query_sql("UPDATE `char` SET `pvp_exp` = `pvp_exp`+100 WHERE `char_id` = '"+getcharid(0)+"' ");
//query_sql ("DELETE FROM bountys WHERE name='"+escape_sql(@name2$)+"'");
//query_sql ("UPDATE bountyladder SET target3='"+@name$+"' WHERE char_id="+getcharid(0)+"");
}
all of them produces a simple error
[sql]: DB error - You have an error in your SQL syntax; check the manual that co
rresponds to your MySQL server version for the right syntax to use near ''char'
WHERE 'char_id' = '150000'' at line 1
[Debug]: at c:\kinbel\src\map\script.c:13127 - DELETE FROM 'char' WHERE 'char_id
' = '150000'
[Debug]: Source (NPC): game_mechanics (invisible/not on a map)
EDIT:
okay so I tried this new syntax and now I get a new error which I am not quite sure why I am getting it.
[sql]: DB error - Unknown column '150000' in 'where clause'
[Debug]: at c:\kinbel\src\map\script.c:13127 - DELETE FROM `char` WHERE `char_id
`=`150000`
[Debug]: Source (NPC): game_mechanics (invisible/not on a map)
The new syntax is
query_sql("DELETE FROM `char` WHERE `char_id`=`"+getcharid(0)+"` ");
EDIT2: I solved it... I feel very..very...very stupid.
Question
Epsynus
Alright people I am having some issues understanding the syntax for query_sql
what I am trying to achieve is to delete the character through a script, and the following are the ways I have tried doing it so far.
any help is appriciated and of course I will pay back to the community with my knowledge!
all of them produces a simple error
EDIT:
okay so I tried this new syntax and now I get a new error which I am not quite sure why I am getting it.
The new syntax is
EDIT2: I solved it... I feel very..very...very stupid.
Edited by Epsynus1 answer to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.