SQL syntax
#1

I still can't seem to find what's wrong with this syntax;

Code:
forward SaveAccount(playerid); public SaveAccount(playerid)
{
    new
        query[1300],
        Float:pos[4],
		pIPp[17];
	GetPlayerIp(playerid, pIPp, sizeof(pIPp));
    GetPlayerPos(playerid, pos[0], pos[1], pos[2]);
    GetPlayerFacingAngle(playerid, pos[3]);
    mysql_format(mysql, query, sizeof(query), "UPDATE `accs` SET `pName` = '%e', `pSecKey` = %d, `pLevel` = %d, `pRespect` = %d, `pSkin` = %d, `pIP` = '%s', `pAdmin` = %d, `pVIP` = %d, `pMoney` = %d, `pGender` = %d, `pAge` = %d, `pBank` = %d, `pBanned` = %d, `pBans` = %d, `pBannedBy` = '%e', `pBanReason` = '%e', `pBanDate` = '%e', `pBanTime` = '%e', `pBanAppealable` = %d, `pFaction` = %d, `pRank` = %d, `pFacSkin` = %d, `pTester` = %d, `pTutStep` = %d, `pFinishedTut` = %d, `pMuted` = %d, `pPosX` = %f, `pPosY` = %f, `pPosZ` = %f, `pPosA` = %f WHERE `pID` = %d",
    pData[playerid][pName], pData[playerid][pSecKey], pData[playerid][pLevel], pData[playerid][pRespect], pData[playerid][pSkin], pIPp, pData[playerid][pAdmin], pData[playerid][pVIP], pData[playerid][pMoney], pData[playerid][pGender], pData[playerid][pAge], pData[playerid][pBank], pData[playerid][pBanned], pData[playerid][pBans], pData[playerid][pBannedBy], pData[playerid][pBanReason], pData[playerid][pBanDate], pData[playerid][pBanAppealable], pData[playerid][pFaction], pData[playerid][pRank], pData[playerid][pFacSkin], pData[playerid][pTester], pData[playerid][pTutStep], pData[playerid][pFinishedTut], pData[playerid][pMuted], pos[0], pos[1], pos[2], pos[3], pData[playerid][pID]);
    mysql_tquery(mysql, query, "", "");
    return 1;
}
Code:
[04:04:16] [SQL][] EID: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 '' at line 1
[04:04:16] UPDATE `accs` SET `pName` = 'Test_Account', `pSecKey` = 0, `pLevel` = 0, `pRespect` = 0, `pSkin` = 0, `pIP` = '255.255.255.255', `pAdmin` = 0, `pVIP` = 0, `pMoney` = 0, `pGender` = 0, `pAge` = 0, `pBank` = 0, `pBanned` = 0, `pBans` = 0, `pBannedBy` = '', `pBanReason` = '', `pBanDate` = '', `pBanTime` = '', `pBanAppealable` = 0, `pFaction` = 0, `pRank` = 0, `pFacSkin` = 0, `pTester` = 0, `pTutStep` = 0, `pFinishedTut` = 0, `pMuted` = 1126786066, `pPosX` = -64.138, `pPosY` = 1.578, `pPosZ` = 7.906, `pPosA` = 7.006e-45 WHERE `pID` =
I don't know why but the first time my IP saved correctly, now it doesn't..

Looking at it, I just saw that pMuted and pPosA shows a very weird value..

Using a test command I made::

Code:
CMD:test(playerid, params[])
{
	new pIPp[20], str[100], Float:pos[4];
	GetPlayerIp(playerid, pIPp, sizeof(pIPp));
    GetPlayerPos(playerid, pos[0], pos[1], pos[2]);
    GetPlayerFacingAngle(playerid, pos[3]);
    format(str, sizeof(str), "X:[%f] Y:[%f] Z:[%f] A:[%f] IP:[%s]", pos[0], pos[1], pos[2], pos[3], pIPp);
    SendClientMessage(playerid, COLOR_HAPPYGREEN, str);
    format(str, sizeof(str), "ENUM X:[%f] Y:[%f] Z:[%f] A:[%f] IP:[%s]", pData[playerid][pPosX], pData[playerid][pPosY], pData[playerid][pPosZ], pData[playerid][pPosA], pData[playerid][pIP]);
    SendClientMessage(playerid, COLOR_HAPPYGREEN, str);
    return 1;
}
Here's a screen of what I see ingame:



pData ip shows correct value, apparently the enum positions isn't being loaded?

Code:
forward OnAccountLoad(playerid); public OnAccountLoad(playerid)
{
	new ipp[20];
	GetPlayerIp(playerid, ipp, sizeof(ipp));
    pData[playerid][pLevel] = cache_get_field_content_int(0, "pLevel");
    pData[playerid][pRespect] = cache_get_field_content_int(0, "pRespect");
    pData[playerid][pSkin] = cache_get_field_content_int(0, "pSkin");
    pData[playerid][pIP] = ipp;
    pData[playerid][pAdmin] = cache_get_field_content_int(0, "pAdmin");
    pData[playerid][pVIP] = cache_get_field_content_int(0, "pVIP");
    pData[playerid][pMoney] = cache_get_field_content_int(0, "pMoney");
    pData[playerid][pGender] = cache_get_field_content_int(0, "pGender");
    pData[playerid][pAge] = cache_get_field_content_int(0, "pAge");
    pData[playerid][pBank] = cache_get_field_content_int(0, "pBank");
    pData[playerid][pBanned] = cache_get_field_content_int(0, "pBanned");
    pData[playerid][pBans] = cache_get_field_content_int(0, "pBans");
    cache_get_field_content(0, "pBannedBy", pData[playerid][pBannedBy]);
    cache_get_field_content(0, "pBanReason", pData[playerid][pBanReason]);
    cache_get_field_content(0, "pBanDate", pData[playerid][pBanDate]);
    cache_get_field_content(0, "pBanTime", pData[playerid][pBanTime]);
    pData[playerid][pBanAppealable] = cache_get_field_content_int(0, "pBanAppealable");
    pData[playerid][pFaction] = cache_get_field_content_int(0, "pFaction");
    pData[playerid][pRank] = cache_get_field_content_int(0, "pRank");
    pData[playerid][pFacSkin] = cache_get_field_content_int(0, "pFacSkin");
    pData[playerid][pPosX] = cache_get_field_content_float(0, "pPosX");
    pData[playerid][pPosY] = cache_get_field_content_float(0, "pPosY");
    pData[playerid][pPosZ] = cache_get_field_content_float(0, "pPosZ");
    pData[playerid][pPosA] = cache_get_field_content_float(0, "pPosA");
    pData[playerid][pTester] = cache_get_field_content_int(0, "pTester");
    pData[playerid][pTutStep] = cache_get_field_content_int(0, "pTutStep");
	pData[playerid][pFinishedTut] = cache_get_field_content_int(0, "pFinishedTut");
	pData[playerid][pMuted] = cache_get_field_content_int(0, "pMuted");

	gPlayerLogged[playerid] = 1;

    GivePlayerMoney(playerid, pData[playerid][pMoney]);
    SendClientMessage(playerid, COLOR_HAPPYGREEN, "You're ready to play! Hit the spawn button to begin!");
    return 1;
}
What could possibly be wrong?
Reply
#2

I have been helped by the amazing Konstantinos, apparently I had 31 specifiers and 30 arguments, forgot "pData[playerid][pBanTime]" in the saving!
Reply
#3

There are 31 placeholders and only 30 variables. You must have missed something. I believe that the value for `pBanTime` is missing.

EDIT: I was too late
Reply
#4

Quote:
Originally Posted by dusk
View Post
There are 31 placeholders and only 30 variables. You must have missed something. I believe that the value for `pBanTime` is missing.

EDIT: I was too late
Yep :P

Thanks anyways!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)