SA-MP Forums Archive
problem in MySQL UPDATE - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: problem in MySQL UPDATE (/showthread.php?tid=566330)



problem in MySQL UPDATE - amirab - 05.03.2015

does anybody know what is the problem ?

it doesn't save stats
and error is this :

Код:
[14:14:55] [ERROR] CMySQLQuery::Execute[] - (error #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 '`ID`=2' at line 1
[14:14:55] [DEBUG] CMySQLQuery::Execute[] - error will be triggered in OnQueryError
my code :

PHP код:
stock SavePlayerStats(playerid)
{
    if(
pData[playerid][Logged] == false) return 1;
    new 
Qry[700];
    
mysql_format(mysqlQrysizeof(Qry), "UPDATE `accounts` SET `Admin`=%d\
                         , `Vip`=%d, `Money`=%d\
                         , `Score` =%d, `GangID` = %d\
                         , `GangLead` = %d, `InGang` =%d\
                         , `Jailed` = %d, `Jail_h` = %d\
                         , `jail_m` = %d, `capsoff` = %d\
                         , `house_o` = %d, `lockpick` = %d\
                         , `drugs` =%d, drugseeds=%d,Bank =%d\
                         , `fight` =%d, `kills` =%d , `deaths` = %d, `highspree` = %d\
                         , `p_hours` =%d\
                          WHERE `ID`=%d"
,
                         
pData[playerid][Admin],
                         
pData[playerid][Vip],
                         
GetCash(playerid),
                         
GetPlayerScore(playerid),
                         
pData[playerid][Gang_ID],
                         
pData[playerid][Gang_LEAD],
                         
pData[playerid][InGang],
                         
pData[playerid][Jailed],
                         
pData[playerid][H_Jailed],
                         
pData[playerid][M_Jailed],
                         
pData[playerid][Capsoff],
                         
pData[playerid][House_o],
                         
pData[playerid][LockPick],
                         
pData[playerid][Drugs],pData[playerid][DrugSeed],pData[playerid][Bank],
                         
pData[playerid][Fight],pData[playerid][Kills],pData[playerid][Deaths],pData[playerid][HIGH_SPREE],
                         
pData[playerid][hours],
                         
pData[playerid][p_ID]);
                          
mysql_tquery(mysqlQry"""");
                          return 
1;




Re: problem in MySQL UPDATE - Misiur - 05.03.2015

It's tricky if you encounter it for the first time:
pawn Код:
, `p_hours` =%d\
                          WHERE `ID`=%d",
Because of the "\" line break, the indentation in next line is ignored, so your query looks like
Quote:

`p_hours`=1231321WHERE `ID`=1234124

Add space before last "\"


Re: problem in MySQL UPDATE - amirab - 05.03.2015

Oh , thanks ! it works now
i always use multi format functions for one query if it's long
and it was my first time using it
so i added a space before WHERE `ID`=
i didn't know that

Thanks , +REP for You