Mysql 1064 SQL syntax error
#1

Hi all,

I have a problem with my mysql script.
If i register my account there is nothing wrong. But when i quit the server i get an error in the server log but the stats are saved good in the database.
And the problem is when i login if i joined again my stats didnt get loaded when i logged in.
Saveplayer:
pawn Code:
stock SavePlayer(playerid)
{
    new h, m, s, Float:health, Float:armour, Float:POS[3];
    TotalGameTime(playerid, h, m, s);
    GetPlayerPos(playerid, POS[0], POS[1], POS[2]);
    GetPlayerHealth(playerid, health);
    GetPlayerArmour(playerid, armour);
    new query[1000];
    new query2[1000];
    format(query, sizeof(query), "UPDATE `"#MYSQL_TABLE"` SET `XPos` = %.2f, `YPos` = %.2f, `ZPos` = %.2f, `AdminLevel` = %d, `VIPLevel` = %d, `WantedLevel` = %d, \
    `Kills` = %d, `Deaths` = %d, `Money` = %d, `Score` = %d, `Health` = %.2f, `Armour` = %.2f, `Hours` = %d, `Minutes` = %d, `Seconds` = %d,",
        POS[0],
        POS[1],
        POS[2],
        PlayerInfo[playerid][AdminLevel],
        PlayerInfo[playerid][VIPLevel],
        GetPlayerWantedLevel(playerid),
        PlayerInfo[playerid][Kills],
        PlayerInfo[playerid][Deaths],
        GetPlayerMoney(playerid),
        GetPlayerScore(playerid),
        health,
        armour,
        h,
        m,
        s);
    format(query2, sizeof(query2), "
`LastSkin` = %d, `KickCount` = %d,`SpawnCount` = %d, `ReportCount` = %d, `Bank` = %d,`Interior` = %d,`World` = %d,`Class` = %d,`Skill` = %d,\
    `FightingStyle` = %d,`Speedo` = %d,`AllowPMS` = %d,`JailTime` = %d,`WantedLevel` = %d,`House` = %d,`SavePos` = %d WHERE `PlayerName` = '%s'",
        PlayerInfo[playerid][LastSkin],
        PlayerInfo[playerid][KickCount],
        PlayerInfo[playerid][SpawnCount],
        PlayerInfo[playerid][ReportCount],
        PlayerInfo[playerid][pBank],
        GetPlayerInterior(playerid),
        GetPlayerVirtualWorld(playerid),
        PlayerInfo[playerid][pClass],
        PlayerInfo[playerid][pSkill],
        GetPlayerFightingStyle(playerid),
        PlayerInfo[playerid][pSpeedo],
        PlayerInfo[playerid][pAllowPMS],
        PlayerInfo[playerid][pJailTime],
        PlayerInfo[playerid][pWantedLevel],
        PlayerInfo[playerid][pHouse],
        PlayerInfo[playerid][pSavePos],
        GetName(playerid));
    strcat(query,query2);
    if(mysql_ping(gSQL))
    {
        mysql_query(query, _THREAD_SAVE_PLAYER, 0, gSQL);//query
    }
}
LoadPlayerwhen i enter the password wrong i get a message, when password is good i didnt receive a message)
pawn Code:
stock LoadPlayer(playerid)//gets called when password is passed good
{
    new query[1000];
    format(query,sizeof(query),"SELECT `XPos`,`YPos`,`ZPos`,`AdminLevel`,`VIPLevel`,`WantedLevel`,`Kills`,`Deaths`,`Money`,`Score`,`Health`,`Armour`,`Hours`,`Minutes`,`Seconds`,`KickCount`,`LastSkin`,`SpawnCount`,`ReportCount`,`RegDate`,`Bank`,`Interior`,`World`,`Class`,`Skill`,`FightingStyle`,`Speedo`,`AllowPMS`,`JailTime`,`WantedLevel`,`House`,`SavePos`, FROM `"#MYSQL_TABLE"` WHERE `PlayerName` = '%s'", GetName(playerid));
    if(mysql_ping(gSQL))
    {
        mysql_query(query, _THREAD_LOAD_PLAYER, playerid, gSQL);
    }
    return 1;
}
OnQueryFinish:
pawn Code:
case _THREAD_LOAD_PLAYER :
        {
            mysql_store_result();
            if(mysql_num_rows(gSQL) > 0)
            {
                new resultline[512], score, money, wanted,interior,world,fightingstyle;
               
                mysql_fetch_row_format(resultline);

                if(sscanf(resultline, "p<|>fffdddddddffddddddds[16]dddddddddddd",
                    PlayerInfo[extraid][XPos],
                    PlayerInfo[extraid][YPos],
                    PlayerInfo[extraid][ZPos],
                    PlayerInfo[extraid][AdminLevel],
                    PlayerInfo[extraid][VIPLevel],
                    wanted,
                    PlayerInfo[extraid][Kills],
                    PlayerInfo[extraid][Deaths],
                    money,
                    score,
                    PlayerInfo[extraid][Health],
                    PlayerInfo[extraid][Armour],
                    PlayerInfo[extraid][Hours],
                    PlayerInfo[extraid][Minutes],
                    PlayerInfo[extraid][Seconds],
                    PlayerInfo[extraid][KickCount],
                    PlayerInfo[extraid][LastSkin],
                    PlayerInfo[extraid][SpawnCount],
                    PlayerInfo[extraid][ReportCount],
                    PlayerInfo[extraid][RegDate],
                    PlayerInfo[extraid][pBank],
                    interior,
                    world,
                    PlayerInfo[extraid][pClass],
                    PlayerInfo[extraid][pSkill],
                    fightingstyle,
                    PlayerInfo[extraid][pSpeedo],
                    PlayerInfo[extraid][pAllowPMS],
                    PlayerInfo[extraid][pJailTime],
                    PlayerInfo[extraid][pWantedLevel],
                    PlayerInfo[extraid][pHouse],
                    PlayerInfo[extraid][pSavePos]))
                    {
                        SendClientMessage(extraid, LIGHT_GREEN, "There was a problem while loading your account");
                        KickEx(extraid);
                        mysql_free_result();
                        return 1;
                    }
                   
                SetPlayerWantedLevel(extraid, wanted);
                GivePlayerMoney(extraid, money);
                SetPlayerScore(extraid, score);
                PlayerInfo[extraid][Logged] = true;
                SetPVarInt(extraid,"Class",PlayerInfo[extraid][pClass]);
                SetPVarInt(extraid,"Skill",PlayerInfo[extraid][pSkill]);
                SetPVarInt(extraid,"Speedo",PlayerInfo[extraid][pSpeedo]);
                SetPVarInt(extraid,"FightingStyle",fightingstyle);
                SetPVarInt(extraid,"AllowPMS",PlayerInfo[extraid][pAllowPMS]);
                SetPVarInt(extraid,"JailTime",PlayerInfo[extraid][pJailTime]);
                SetPVarInt(extraid,"WantedLevel",PlayerInfo[extraid][pWantedLevel]);
                SetPVarInt(extraid,"House",PlayerInfo[extraid][pHouse]);
                if(PlayerInfo[extraid][AdminLevel] > 0)
                {
                     
                    format(globalstring,sizeof(globalstring),"Successfully logged in. (Adminlevel %d)", PlayerInfo[extraid][AdminLevel]);
                    SendClientMessage(extraid,GREEN,globalstring);
                } else SendClientMessage(extraid,GREEN,"Successfully logged in!");
            }
            mysql_free_result();
        }
Server Log:
Code:
[09:41:07] 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 'WHERE `PlayerName` = 'Admigo'' at line 1, OnQueryFinish, UPDATE `Account` SET `XPos` = 1461.75, `YPos` = 2773.64, `ZPos` = 10.82, `AdminLevel` = 0, `VIPLevel` = 0, `WantedLevel` = 0, `Kills` = 0, `Deaths` = 0, `Money` = 0, `Score` = 0, `Health` = 100.00, `Armour` = 0.00, `Hours` = 0, `Minutes` = 0, `Seconds` = 24,`LastSkin` = 0, `KickCount` = 0,`SpawnCount` = 1, `ReportCount` = 0, `Bank` = 0,`Interior` = 0,`World` = 0,`Class` = 0,`Skill` = 0,`FightingStyle` = 4,`Speedo` = 0,`AllowPMS` = 0,`JailTime` = 0,`WantedLevel` = 0,`House` = 0,`SavePos` = 1,WHERE `PlayerName` = 'Admigo', 1
How can i fix this?

Admigo
Reply
#2

Remove the comma just before the WHERE clause.

pawn Code:
`SavePos` = 1,WHERE
EDIT: Doesn't seem that's actually in your code but it's showing on the error
Reply
#3

Quote:
Originally Posted by iggy1
View Post
Remove the comma just before the WHERE clause.

pawn Code:
`SavePos` = 1,WHERE
EDIT: Doesn't seem that's actually in your code but it's showing on the error
Thanks, edited the code. But what about the loading problem?
Reply
#4

Now error:
Code:
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 'FROM `Account` WHERE `PlayerName` = 'Admigo'' at line 1, OnQueryFinish, SELECT `XPos`,`YPos`,`ZPos`,`AdminLevel`,`VIPLevel`,`WantedLevel`,`Kills`,`Deaths`,`Money`,`Score`,`Health`,`Armour`,`Hours`,`Minutes`,`Seconds`,`KickCount`,`LastSkin`,`SpawnCount`,`ReportCount`,`RegDate`,`Bank`,`Interior`,`World`,`Class`,`Skill`,`FightingStyle`,`Speedo`,`AllowPMS`,`JailTime`,`WantedLevel`,`House`,`SavePos`, FROM `Account` WHERE `PlayerName` = 'Admigo', 1
EDIT:SOLVED.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)