[SQL] Updating
#1

This is the error :

Код:
[Tue Apr 30 21:02:03 2013] Function: mysql_query executed: "UPDATE players SET `jskill` = '0',`mskill` = '0',`dskill` = '0',`fskill` = '0', WHERE id = '153'" with result: "1".
[Tue Apr 30 21:02:03 2013] Error (0): Failed to exeute query. 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 'WHERE id = '153'' at line 1.
And this is the code :
pawn Код:
...
format(query, sizeof(query), "UPDATE players SET `jskill` = '%d',`mskill` = '%d',`dskill` = '%d',`fskill` = '%d', WHERE id = '%d'",PlayerInfo[playerid][jskill],PlayerInfo[playerid][mskill],PlayerInfo[playerid][dskill],PlayerInfo[playerid][fskill],PlayerInfo[playerid][SQLID]);
        mysql_query(query);
..
ps : the query variabile is 1024 in size , so tha'ts not the problem

LE : Here is the sql
Reply
#2

Delete , before WHERE and when you are saving numbers ' ' are useless and every column has to be betwen ` `
Correct code:
pawn Код:
format(query, sizeof(query), "UPDATE `players` SET `jskill` = %d,`mskill` = %d,`dskill` = %d ,`fskill` =  %d WHERE `id` = %d LIMIT 1",PlayerInfo[playerid][jskill],PlayerInfo[playerid][mskill],PlayerInfo[playerid][dskill],PlayerInfo[playerid][fskill],PlayerInfo[playerid][SQLID]);
I also added Limit to prevent affecting multiple rows
Reply
#3

Ty for the fast answer .
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)