MySQL syntax problem.
#1

pawn Код:
stock SavePlayer(playerid)
{
    new
        query[1264]
    ;
    format(query,sizeof(query),"UPDATE `users` SET `job` = '%i', `jobh` = '%i', `jobrank` = '%i', `paycheck` = '%i', `primwea` = '%i'",
    PlayerInfo[playerid][pJob],PlayerInfo[playerid][pJobH],PlayerInfo[playerid][pJobRank],PlayerInfo[playerid][pPayCheck],PlayerInfo[playerid][pPrimWeap]);
    print("Debug");
    format(query,sizeof(query),"%s, `primweapammo` = '%i', `secweap` = '%i', `secweapammo` = '%i', `melee` = '%i', `mask` = '%i', `hours` = '%i'",
    query,PlayerInfo[playerid][pPrimWeapA],PlayerInfo[playerid][pSecWeap],PlayerInfo[playerid][pSecWeapA],PlayerInfo[playerid][pMelee],PlayerInfo[playerid][pMask],PlayerInfo[playerid][pHours]);
    print("Debug");
    format(query,sizeof(query),"%s, `exp` = '%i', `level` = '%i', `phone` = '%i', `skin` = '%i', `donatorlvl` = '%i', `weplic` = '%i', `flylic` = '%i', `drivelic` = '%i'",
    query,PlayerInfo[playerid][pExp], PlayerInfo[playerid][pLevel],PlayerInfo[playerid][pPhone],PlayerInfo[playerid][pSkin],PlayerInfo[playerid][pDonlvl], PlayerInfo[playerid][pWeplic] ? 1:0,PlayerInfo[playerid][pFlylic] ? 1:0, PlayerInfo[playerid][pDrivelic] ? 1:0);
    print("Debug");
    format(query,sizeof(query),"%s, `faction` = '%i', `rank` = '%i', `jailed` = '%i', `jtime` = '%i'",
    query,PlayerInfo[playerid][pFaction], PlayerInfo[playerid][pRank], PlayerInfo[playerid][pJailed],PlayerInfo[playerid][pJTime]);
    print("Debug");
    format(query,sizeof(query),"%s, `cash` = '%i', `savings` = '%i', `bizkey` = '%i', `alevel` = '%i', `hkey` = '%i,%i,%i', `spawn` = '%.1f,%.1f,%.1f', `accepted` = '1', `mseeds` = '%i', `boxx` = '%i', `boxy` = '%i', `boxz` = '%i'",
    query, ACData[playerid][Money], PlayerInfo[playerid][pSavings], PlayerInfo[playerid][pBizKey], PlayerInfo[playerid][pAdmin], PlayerInfo[playerid][pHKey][0],PlayerInfo[playerid][pHKey][1],PlayerInfo[playerid][pHKey][2], PlayerInfo[playerid][pSpawn][0],PlayerInfo[playerid][pSpawn][1],PlayerInfo[playerid][pSpawn][2],PlayerInfo[playerid][pMSeeds],PlayerInfo[playerid][pBoxX],PlayerInfo[playerid][pBoxY],PlayerInfo[playerid][pBoxZ]);
    print("Debug");
    format(query,sizeof(query),"%s, `tester` = '%i', `vkeys` = '%i,%i,%i,%i,%i,%i,%i,%i,%i,%i', `psentences` = '%i', `jsentences` = '%i', `bwounded` = '%i', `crash` = '%.1f,%.1f,%.1f', `bank` = '%i'",query,PlayerInfo[playerid][pTester],
    PlayerInfo[playerid][pVKey][0],PlayerInfo[playerid][pVKey][1],PlayerInfo[playerid][pVKey][2],PlayerInfo[playerid][pVKey][3],PlayerInfo[playerid][pVKey][4],PlayerInfo[playerid][pVKey][5],
    PlayerInfo[playerid][pVKey][6],PlayerInfo[playerid][pVKey][7],PlayerInfo[playerid][pVKey][8],PlayerInfo[playerid][pVKey][9],PlayerInfo[playerid][pPSen],PlayerInfo[playerid][pJSen],PlayerInfo[playerid][pWounded],PlayerInfo[playerid][pCrash][0],PlayerInfo[playerid][pCrash][1],PlayerInfo[playerid][pCrash][2],
    PlayerInfo[playerid][pBank]);
    print("Debug");
    format(query,sizeof(query),"%s, `balance` = '%i', `savings` = '%i', `fpoints` = '%i', `dpoints` = '%i', `spawnedveh` = '%i', `rent` = '%i', `defacc` = '%i', `radio` = '%i', `rfreq` = '%i,%i,%i'",
    query,PlayerInfo[playerid][pBalance],PlayerInfo[playerid][pSavings],PlayerInfo[playerid][pFPoints],PlayerInfo[playerid][pDPoints],PlayerInfo[playerid][SpawnedVehicle],PlayerInfo[playerid][pRentPrice],PlayerInfo[playerid][pDefAcc],PlayerInfo[playerid][pRadio],PlayerInfo[playerid][pRadioF][0],PlayerInfo[playerid][pRadioF][1],PlayerInfo[playerid][pRadioF][2]);
    print("Debug");
    format(query,sizeof(query),"%s, `weappacks` = '%i,%i,%i,%i,%i,%i,%i,%i,%i,%i,%i,%i', `weappacka` = '%i,%i,%i,%i,%i,%i,%i,%i,%i,%i,%i,%i', `dpack` = '%i,%i,%i,%i,%i,%i,%i,%i,%i,%i,%i,%i,%i,%i,%i,%i,%i,%i,%i,%i', `dpacka` = '%i,%i,%i,%i,%i,%i,%i,%i,%i,%i,%i,%i,%i,%i,%i,%i,%i,%i,%i,%i', `dpacks` = '%i,%i,%i,%i,%i,%i,%i,%i,%i,%i,%i,%i,%i,%i,%i,%i,%i,%i,%i,%i'", query,
    PlayerInfo[playerid][pWPack][0],PlayerInfo[playerid][pWPack][1],PlayerInfo[playerid][pWPack][2],PlayerInfo[playerid][pWPack][3],PlayerInfo[playerid][pWPack][4],PlayerInfo[playerid][pWPack][5],PlayerInfo[playerid][pWPack][6],PlayerInfo[playerid][pWPack][7],PlayerInfo[playerid][pWPack][8],PlayerInfo[playerid][pWPack][9],PlayerInfo[playerid][pWPack][10],PlayerInfo[playerid][pWPack][11],
    PlayerInfo[playerid][pWPackA][0],PlayerInfo[playerid][pWPackA][1],PlayerInfo[playerid][pWPackA][2],PlayerInfo[playerid][pWPackA][3],PlayerInfo[playerid][pWPackA][4],PlayerInfo[playerid][pWPackA][5],PlayerInfo[playerid][pWPackA][6],PlayerInfo[playerid][pWPackA][7],PlayerInfo[playerid][pWPackA][8],PlayerInfo[playerid][pWPackA][9],PlayerInfo[playerid][pWPackA][10],PlayerInfo[playerid][pWPackA][11],
    PlayerInfo[playerid][pDPack][0],PlayerInfo[playerid][pDPack][1],PlayerInfo[playerid][pDPack][2],PlayerInfo[playerid][pDPack][3],PlayerInfo[playerid][pDPack][4],PlayerInfo[playerid][pDPack][5],PlayerInfo[playerid][pDPack][6],PlayerInfo[playerid][pDPack][7],PlayerInfo[playerid][pDPack][8],PlayerInfo[playerid][pDPack][9],PlayerInfo[playerid][pDPack][10],PlayerInfo[playerid][pDPack][11],
    PlayerInfo[playerid][pDPack][12],PlayerInfo[playerid][pDPack][13],PlayerInfo[playerid][pDPack][14],PlayerInfo[playerid][pDPack][15],PlayerInfo[playerid][pDPack][16],PlayerInfo[playerid][pDPack][17],PlayerInfo[playerid][pDPack][18],PlayerInfo[playerid][pDPack][19], PlayerInfo[playerid][pDPackA][0],PlayerInfo[playerid][pDPackA][1],PlayerInfo[playerid][pDPackA][2],PlayerInfo[playerid][pDPackA][3],
    PlayerInfo[playerid][pDPackA][4],PlayerInfo[playerid][pDPackA][5],PlayerInfo[playerid][pDPackA][6],PlayerInfo[playerid][pDPackA][7],PlayerInfo[playerid][pDPackA][8],PlayerInfo[playerid][pDPackA][9],PlayerInfo[playerid][pDPackA][10], PlayerInfo[playerid][pDPackA][11],PlayerInfo[playerid][pDPackA][12],PlayerInfo[playerid][pDPackA][13],PlayerInfo[playerid][pDPackA][14],PlayerInfo[playerid][pDPackA][15],
    PlayerInfo[playerid][pDPackA][16],PlayerInfo[playerid][pDPackA][17],PlayerInfo[playerid][pDPackA][18],PlayerInfo[playerid][pDPackA][19],PlayerInfo[playerid][pDPackS][0],PlayerInfo[playerid][pDPackS][1],PlayerInfo[playerid][pDPackS][2],PlayerInfo[playerid][pDPackS][3],PlayerInfo[playerid][pDPackS][4],PlayerInfo[playerid][pDPackS][5],PlayerInfo[playerid][pDPackS][6],PlayerInfo[playerid][pDPackS][7],
    PlayerInfo[playerid][pDPackS][8],PlayerInfo[playerid][pDPackS][9],PlayerInfo[playerid][pDPackS][10],PlayerInfo[playerid][pDPackS][11],PlayerInfo[playerid][pDPackS][12],PlayerInfo[playerid][pDPackS][13],PlayerInfo[playerid][pDPackS][14],PlayerInfo[playerid][pDPackS][15],PlayerInfo[playerid][pDPackS][16],PlayerInfo[playerid][pDPackS][17],PlayerInfo[playerid][pDPackS][18],PlayerInfo[playerid][pDPackS][19]);
    format(query,sizeof(query),"%s, `hunger` = '%i', `addiction` = '%i', `addictionl` = '%i', `cstyle` = '%i', `pseeds` = '%i', `cseeds` = '%i', `mgseeds` = '%i' WHERE `id` = '%i'",query,PlayerInfo[playerid][pHunger],PlayerInfo[playerid][pAddiction],PlayerInfo[playerid][pAddictionL],PlayerInfo[playerid][pCStyle],PlayerInfo[playerid][pPSeeds],PlayerInfo[playerid][pCSeeds],PlayerInfo[playerid][pMGSeeds],PlayerInfo[playerid][pUID]);
    print("Debug");
    mysql_query(query);
    print("Debug");
    return 1;
}
When this stock activates, it says in the black window:
Код:
[14:16:29] [MySQL] 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 '' at line 1.
Help please! I tried to execute it on the phpmyadmin replacing the %i in 1 and it worked, but it doesn't work with the code and shows the error above!
Reply
#2

Well thing is... I don't know can you do it like this
pawn Код:
`weappacks` = '%i,%i,%i,%i,%i,%i,%i,%i,%i,%i,%i,%i'
Is Column weappacks VARCHAR or INT?
Reply
#3

Quote:
Originally Posted by [MG]Dimi
Посмотреть сообщение
Well thing is... I don't know can you do it like this
pawn Код:
`weappacks` = '%i,%i,%i,%i,%i,%i,%i,%i,%i,%i,%i,%i'
Is Column weappacks VARCHAR or INT?
VARCHAR.
Reply
#4

My dear god, that is a huge query and even if there's a real syntax error, finding it would be a pain, but I do have a few suggestions for you, starting with the most basic one: DO NOT SAVE DATA WHEN IT DOES NOT CHANGE.

For example, you're saving player's phone value (PlayerInfo[playerid][pPhone]). But how often is this actually changed? Inside a command or few, am I right? Then why do you save it in SavePlayer(playerid) function?
There are plenty of ways to use MySQL saving properly and efficiently as well, you should take advantage of those!
Reply
#5

Quote:
Originally Posted by AndreT
Посмотреть сообщение
My dear god, that is a huge query and even if there's a real syntax error, finding it would be a pain, but I do have a few suggestions for you, starting with the most basic one: DO NOT SAVE DATA WHEN IT DOES NOT CHANGE.

For example, you're saving player's phone value (PlayerInfo[playerid][pPhone]). But how often is this actually changed? Inside a command or few, am I right? Then why do you save it in SavePlayer(playerid) function?
There are plenty of ways to use MySQL saving properly and efficiently as well, you should take advantage of those!
But how can I set it that it will save pPhone only when it'll change? can you show me the other ways to save into MySQL?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)