PDA

View Full Version : Mysql saving stats problem


SilentSoul
07/12/2013, 06:48 AM
Hello guys , i have an error on my mysql and i try to search about how to fix that but i can't find

Mysql logs!
[Fri Dec 06 22:35:49 2013] [Sat Dec 07 00:26:47 2013] Function: mysql_query executed: "UPDATE `playerdata` SET `admin` = '0', `score` = '0', `money` = '0' ,`kills` = '0','deaths' = '0',`skin` = '0',`muted` = '0','banned' = '0','Online' ='0 h 1 m 45 s','Vip' = '0' WHERE `id` = '3' LIMIT 1" with result: "1".
[Sat Dec 07 00:26:47 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 ''deaths' = '0',`skin` = '0',`muted` = '0','banned' = '0','Online' ='0 h 1 m 45 s' at line 1.

My Script
SavePlayer(playerid)
{
if(PlayerInfo[playerid][Logged] == 1)
{
new Query[700],hh, mm, ss;
GetPlayerOnlineTime(playerid, hh, mm, ss);
format(Query, 500, "UPDATE `playerdata` SET `admin` = '%d', `score` = '%d', `money` = '%d' ,`kills` = '%d','deaths' = '%d',`skin` = '%d',`muted` = '%d','banned' = '%d','Online' ='%i h %i m %i s','Vip' = '%d' WHERE `id` = '%d' LIMIT 1",
PlayerInfo[playerid][pAdminLevel],
PlayerInfo[playerid][pScore],
PlayerInfo[playerid][pMoney],
PlayerInfo[playerid][pKills],
PlayerInfo[playerid][pDeaths],
PlayerInfo[playerid][pSkin],
PlayerInfo[playerid][pMuted],
PlayerInfo[playerid][pBanned],
hh,
mm,
ss,
PlayerInfo[playerid][pVip],
PlayerInfo[playerid][ID]);
mysql_query(Query);
}
}

Tayab
07/12/2013, 07:48 AM
Missing a apostrophe of the death field. This should work.

SavePlayer(playerid)
{
if(PlayerInfo[playerid][Logged] == 1)
{
new Query[700],hh, mm, ss;
GetPlayerOnlineTime(playerid, hh, mm, ss);
format(Query, 500, "UPDATE `playerdata` SET `admin` = '%d', `score` = '%d', `money` = '%d' ,`kills` = '%d',`deaths` = '%d',`skin` = '%d',`muted` = '%d','banned' = '%d','Online' ='%i h %i m %i s','Vip' = '%d' WHERE `id` = '%d' LIMIT 1",
PlayerInfo[playerid][pAdminLevel],
PlayerInfo[playerid][pScore],
PlayerInfo[playerid][pMoney],
PlayerInfo[playerid][pKills],
PlayerInfo[playerid][pDeaths],
PlayerInfo[playerid][pSkin],
PlayerInfo[playerid][pMuted],
PlayerInfo[playerid][pBanned],
hh,
mm,
ss,
PlayerInfo[playerid][pVip],
PlayerInfo[playerid][ID]);
mysql_query(Query);
}
}

SilentSoul
07/12/2013, 07:58 AM
I already notice that after a while , but still not working after fixing this issue :/ !,anyway thanks for trying to help!

Konstantinos
07/12/2013, 12:03 PM
Not only on death, but banned, online, vip too.


format(Query, 500, "UPDATE playerdata SET admin = %d, score = %d, money = %d, kills = %d, deaths = %d, skin = %d, muted = %d, banned = %d, Online = '%i h %i m %i s', Vip = %d WHERE id = %d LIMIT 1",
// arguments..


Grave accent (`) is not obligatory, so you can reduce the query's size by not using them. Same goes for Apostrophes around integers, floats. They're only needed in strings.