SA-MP Forums Archive
MySQL error: 1064 when trying to save ip - 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: MySQL error: 1064 when trying to save ip (/showthread.php?tid=408334)



MySQL error: 1064 when trying to save ip - nickdodd25 - 17.01.2013

Hi,
I am currently switching my gamemode over to the r7 MySQL plugin and i have the system working great but for some reason when i added ip's to save when the player connects/disconnects i get a syntax error...
Код:
ERROR: id:1064 error: 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 '.0.1, pID = E40DF9FA90D5E8CDFE490040FDEDE98E8F40888, laston = 1358455071 WHERE `' at line 1 query: UPDATE `playerinfo` SET money = 10119, bank = 0, bankon = 0, adminlvl = 5, kills = 50, sig = 1, deaths = 60, score = 21, on‌line = 0, rules = 0, registered = 1, bans = 0, viplevel = 3, vipdays = 1373867448, vipskin = 282, mmute = 0, mstop = 0, hours = 0, minutes = 15, seconds = 12, speedset = 0, auto = 1, IP = 127.0.0.1, pID = E40DF9FA90D5E8CDFE490040FDEDE98E8F40888, laston = 1358455071 WHERE `id` = 1
From what i read out of that something would be wrong between pID and laston. Now both are in the database and spelled correctly. Here is the code i use for saving.....
pawn Код:
stock SaveAccount(playerid)
{
    new query[1700];
    new ip[MAX_PLAYER_IP];
    new id[80];
    new laston = gettime();
    mysql_real_escape_string(jIP[playerid],ip);
    mysql_real_escape_string(jID[playerid],id);
    format(query, sizeof(query), "UPDATE `playerinfo` SET money = %i, bank = %i, bankon = %i, adminlvl = %i, kills = %i, sig = %i, deaths = %i, score = %i, on‌line = %i, rules = %i, registered = %i, bans = %i, viplevel = %i, vipdays = %i, vipskin = %i, mmute = %i, mstop = %i, hours = %i, minutes = %i, seconds = %i, speedset = %i, auto = %i, IP = %s, pID = %s, laston = %i WHERE `id` = %d",
        PlayerInfo[playerid][pCash],
        PlayerInfo[playerid][pBank],
        PlayerInfo[playerid][pBankOn],
        PlayerInfo[playerid][pAdmin],
        PlayerInfo[playerid][pKills],
        PlayerInfo[playerid][pSig],
        PlayerInfo[playerid][pDeaths],
        PlayerInfo[playerid][pScore],
        PlayerInfo[playerid][pLoggedIn],
        PlayerInfo[playerid][pRules],
        PlayerInfo[playerid][pRegister],
        PlayerInfo[playerid][pBans],
        PlayerInfo[playerid][pVip],
        PlayerInfo[playerid][pVipTime],
        PlayerInfo[playerid][pVipSkin],
        PlayerInfo[playerid][pMMute],
        PlayerInfo[playerid][pMStop],
        PlayerInfo[playerid][pHours],
        PlayerInfo[playerid][pMinutes],
        PlayerInfo[playerid][pSeconds],
        PlayerInfo[playerid][pSpeedSet],
        PlayerInfo[playerid][pAuto],
        ip,
        id,
        laston,
        PlayerInfo[playerid][pSQLid]

    );

    mysql_function_query(g_Handle, query, false, "SendQuery", "");
    return 1;
}
Now when i change
pawn Код:
IP = %s, pID = %s
//to
IP = %i, pID = %i
It works but obviously will not print out the correct things.
Also pID uses gpci
pawn Код:
native gpci (playerid, serial [], len);
for offline banning purposes.
Is it something i am doing wrong in the query? Or am i going nuts and totally over looking something? I have been trying to figure this out by searching/debugging and it should work but doesn't.
If anyone needs more info let me know.

Thanks


Re: MySQL error: 1064 when trying to save ip - Vince - 17.01.2013

Strings must be wrapped in single quotes when used in a SQL statement.


Re: MySQL error: 1064 when trying to save ip - nickdodd25 - 17.01.2013

Ah thanks alot, figured it was something i totally over looked.
Thanks!!