A little trouble with a "larger than usual" MySQL query (Error 1064)
#1

Hi there,

Recently I've been attempting to create an auto-saving function for my server that'll save all the player's variables as soon as he disconnects & at every Payday. However, I've had some issues, here's the Debug.txt for the issue:

Quote:

[14:07:47] CMySQLHandler::Query(1|testacc1|ec7a040055a4b2b5ca f07d58420239e64b8ca80b|1|0|6|3|0|0|1|0|0|0|0|0|0|0 |0|0|0|0|0|0|0|0|0|0|-1|-1|0|-1|-1|-1|-1|0|0|0|0|0|0|0|0|0|0|0) - An error has occured. (Error ID: 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 '1|testacc1|ec7a040055a4b2b5caf07d58420239e64b8ca8 0b|1|0|6|3|0|0|1|0|0|0|0|0|0|0|0|0|' at line 1)

I've been trying to do a lot of stuff to try and get this to work, but I simply can't. The following code is the saving function that I've been using:

pawn Код:
public UpdateAccount(playerid)
{
    GetPlayerName(playerid, sender, sizeof(sender));
    new updatequery[1000];
    new string[100];
    new level = PlayerData[playerid][pLevel];
    new respect = PlayerData[playerid][pRespect];
    new admin = PlayerData[playerid][pAdmin];
    new helper = PlayerData[playerid][pHelper];
    new premium = PlayerData[playerid][pPremium];
    new sex = PlayerData[playerid][pSex];
    new muted = PlayerData[playerid][pMuted];
    new jailed = PlayerData[playerid][pJailed];
    new ajailed = PlayerData[playerid][pAJailed];
    new cash = PlayerData[playerid][pCash];
    new bank = PlayerData[playerid][pBank];
    new crimes = PlayerData[playerid][pCrimes];
    new kills = PlayerData[playerid][pKills];
    new deaths = PlayerData[playerid][pDeaths];
    new arrested = PlayerData[playerid][pArrested];
    new wanteddeaths = PlayerData[playerid][pWantedDeaths];
    new phonebook = PlayerData[playerid][pPhoneBook];
    new job = PlayerData[playerid][pJob];
    new contract = PlayerData[playerid][pContract];
    new materials = PlayerData[playerid][pMaterials];
    new drugs = PlayerData[playerid][pDrugs];
    new member = PlayerData[playerid][pFaction];
    new rank = PlayerData[playerid][pRank];
    new skin = PlayerData[playerid][pSkin];
    new fskin = PlayerData[playerid][pFSkin];
    new credit = PlayerData[playerid][pCredit];
    new number = PlayerData[playerid][pNumber];
    new house = PlayerData[playerid][pHouse];
    new rent = PlayerData[playerid][pRent];
    new business = PlayerData[playerid][pBusiness];
    new hoursplayed = PlayerData[playerid][pHoursPlayed];
    new carlicense = PlayerData[playerid][pCarLicense];
    new boatlicense = PlayerData[playerid][pBoatLicense];
    new flyinglicense = PlayerData[playerid][pFlyingLicense];
    new bikelicense = PlayerData[playerid][pBikeLicense];
    new weaponlicense = PlayerData[playerid][pWeaponLicense];
    new materialslicense = PlayerData[playerid][pMaterialsLicense];
    new warns = PlayerData[playerid][pWarns];
    new fwarns = PlayerData[playerid][pFWarns];
    new wantedlevel = PlayerData[playerid][pWantedLevel];
    new newbie = PlayerData[playerid][pNewbieChat];
    format(updatequery, sizeof(updatequery), "UPDATE `rp_users` SET");
    format(string, sizeof(string), " `user_level`='%d',", level);
    strcat(updatequery, string);
    format(string, sizeof(string), " `user_respect`='%d',", respect);
    strcat(updatequery, string);
    format(string, sizeof(string), " `user_admin`='%d',", admin);
    strcat(updatequery, string);
    format(string, sizeof(string), " `user_helper`='%d',", helper);
    strcat(updatequery, string);
    format(string, sizeof(string), " `user_premium`='%d',", premium);
    strcat(updatequery, string);
    format(string, sizeof(string), " `user_sex`='%d',", sex);
    strcat(updatequery, string);
    format(string, sizeof(string), " `user_muted`='%d',", muted);
    strcat(updatequery, string);
    format(string, sizeof(string), " `user_jailed`='%d',", jailed);
    strcat(updatequery, string);
    format(string, sizeof(string), " `user_ajailed`='%d',", ajailed);
    strcat(updatequery, string);
    format(string, sizeof(string), " `user_cash`='%d',", cash);
    strcat(updatequery, string);
    format(string, sizeof(string), " `user_bank`='%d',", bank);
    strcat(updatequery, string);
    format(string, sizeof(string), " `user_crimes`='%d',", crimes);
    strcat(updatequery, string);
    format(string, sizeof(string), " `user_kills`='%d',", kills);
    strcat(updatequery, string);
    format(string, sizeof(string), " `user_deaths`='%d',", deaths);
    strcat(updatequery, string);
    format(string, sizeof(string), " `user_arrested`='%d',", arrested);
    strcat(updatequery, string);
    format(string, sizeof(string), " `user_wanteddeaths`='%d',", wanteddeaths);
    strcat(updatequery, string);
    format(string, sizeof(string), " `user_phonebook`='%d',", phonebook);
    strcat(updatequery, string);
    format(string, sizeof(string), " `user_job`='%d',", job);
    strcat(updatequery, string);
    format(string, sizeof(string), " `user_contract`='%d',", contract);
    strcat(updatequery, string);
    format(string, sizeof(string), " `user_materials`='%d',", materials);
    strcat(updatequery, string);
    format(string, sizeof(string), " `user_drugs`='%d',", drugs);
    strcat(updatequery, string);
    format(string, sizeof(string), " `user_member`='%d',", member);
    strcat(updatequery, string);
    format(string, sizeof(string), " `user_rank`='%d',", rank);
    strcat(updatequery, string);
    format(string, sizeof(string), " `user_skin`='%d',", skin);
    strcat(updatequery, string);
    format(string, sizeof(string), " `user_fskin`='%d',", fskin);
    strcat(updatequery, string);
    format(string, sizeof(string), " `user_credit`='%d',", credit);
    strcat(updatequery, string);
    format(string, sizeof(string), " `user_number`='%d',", number);
    strcat(updatequery, string);
    format(string, sizeof(string), " `user_house`='%d',", house);
    strcat(updatequery, string);
    format(string, sizeof(string), " `user_rent`='%d',", rent);
    strcat(updatequery, string);
    format(string, sizeof(string), " `user_business`='%d',", business);
    strcat(updatequery, string);
    format(string, sizeof(string), " `user_hoursplayed`='%d',", hoursplayed);
    strcat(updatequery, string);
    format(string, sizeof(string), " `user_carlicense`='%d',", carlicense);
    strcat(updatequery, string);
    format(string, sizeof(string), " `user_boatlicense`='%d',", boatlicense);
    strcat(updatequery, string);
    format(string, sizeof(string), " `user_flyinglicense`='%d',", flyinglicense);
    strcat(updatequery, string);
    format(string, sizeof(string), " `user_bikelicense`='%d',", bikelicense);
    strcat(updatequery, string);
    format(string, sizeof(string), " `user_weaponlicense`='%d',", weaponlicense);
    strcat(updatequery, string);
    format(string, sizeof(string), " `user_materialslicense`='%d',", materialslicense);
    strcat(updatequery, string);
    format(string, sizeof(string), " `user_warns`='%d',", warns);
    strcat(updatequery, string);
    format(string, sizeof(string), " `user_fwarns`='%d',", fwarns);
    strcat(updatequery, string);
    format(string, sizeof(string), " `user_wantedlevel`='%d',", wantedlevel);
    strcat(updatequery, string);
    format(string, sizeof(string), " `user_newbie`='%d'", newbie);
    strcat(updatequery, string);
    format(string, sizeof(string), " WHERE `user_name`='%s'", sender);
    strcat(updatequery, string);
    mysql_query(query);
}
Any help would be appreciated, thanks.
Reply
#2

Try printing the query at the end into a file, then check if it's completely being sent or not!
pawn Код:
public UpdateAccount(playerid)
{
   // After strcat..
   new File: _file = fopen("mysql_errors.txt");
   if( _file )
   {
          fwrite( update_query )..
   ....
That would help you!
Reply
#3

Its in LoadAccount i think, not in Update
Reply
#4

Quote:
Originally Posted by Rajat_Pawar
Посмотреть сообщение
Try printing the query at the end into a file, then check if it's completely being sent or not!
pawn Код:
public UpdateAccount(playerid)
{
   // After strcat..
   new File: _file = fopen("mysql_errors.txt");
   if( _file )
   {
          fwrite( update_query )..
   ....
That would help you!
The full query is being sent, I already tested this.

Quote:
Originally Posted by Jefff
Посмотреть сообщение
Its in LoadAccount i think, not in Update
Didn't get'ya there, the thing I want it to do is update the account that I specify, which it should do..
Reply
#5

Nevermind, I'll use the good old way of updating anything when something happens :P.
Reply
#6

EDIT: DanishHaq found the problem. The query was updatequery, but he used query by accident.
Reply
#7

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
I think Jefff mentioned loading because when it uses SELECT clause, the result is separated with vertical bars (|).

Are you sure that's the correct query?

PS: Don't you use latest version of MySQL? Threaded queries are always better!
I'm sure the query is fine, I've triple checked if all the table names match up with the things I am updating, and they do, I don't see why it shouldn't work. Perhaps I'll try and fix it one night when I can't sleep lol. And yea, I'm not using the latest version at this moment in time, still trying to get the hang of threaded queries, not my thing lol :P.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)