MySQL save problem (BIG string)
#1

Basically, I have a really big string while saving, the current one is only able to read about... half of it. Is there a better way I can do this without increasing the string size - However I'm sure I wouldn't be able to increase the string so much so it all fit. (From my understanding - Big string = bad - Memory)

pawn Код:
stock savePlayer(playerid)
{
    new
        szQuery[1024];  // Since we're going to save a lot of data, our query size will need to be big.

    PlayerInfo[playerid][pSkin] = GetPlayerSkin(playerid);
    PlayerInfo[playerid][pCash] = GetPlayerMoney(playerid);
    PlayerInfo[playerid][pINT] = GetPlayerInterior(playerid);
    PlayerInfo[playerid][pVW] = GetPlayerVirtualWorld(playerid);
    PlayerInfo[playerid][pWantedLevel] = GetPlayerWantedLevel(playerid);
    new
        Float:x,
        Float:y,
        Float:z
    ;
    GetPlayerHealth(playerid,PlayerInfo[playerid][pHealth]);
    GetPlayerArmour(playerid,PlayerInfo[playerid][pArmor]);
    GetPlayerPos(playerid,x,y,z);
    PlayerInfo[playerid][pPos_x] = x;
    PlayerInfo[playerid][pPos_y] = y;
    PlayerInfo[playerid][pPos_z] = z;
    GetPlayerPos(playerid,PlayerInfo[playerid][pPos_x],PlayerInfo[playerid][pPos_y],PlayerInfo[playerid][pPos_z]);

    format(szQuery, sizeof(szQuery), "UPDATE players SET Cash = '%d', Deposit = '%d', CreditCard = '%d', PayDay = '%d', PayCheck = '%d', ConnectTime = '%d'", PlayerInfo[playerid][pCash], PlayerInfo[playerid][pDeposit], PlayerInfo[playerid][pCreditCard], PlayerInfo[playerid][pPayDay], PlayerInfo[playerid][pPayCheck], PlayerInfo[playerid][pConnectTime]);
    format(szQuery, sizeof(szQuery), "%s, WRestricted = '%d', Age = '%d', Sex = '%d', Level = '%d', HasCellphone = '%d', Internet = '%d'", szQuery, PlayerInfo[playerid][pWRestricted], PlayerInfo[playerid][pAge], PlayerInfo[playerid][pSex], PlayerInfo[playerid][pLevel], PlayerInfo[playerid][pHasCellphone], PlayerInfo[playerid][pInternet]);
    format(szQuery, sizeof(szQuery), "%s, Song1 = '%d', Song2 = '%d', Number = '%d', SpeakerPhone = '%d', PB = '%d' , PhonePrivacy = '%d'", szQuery, PlayerInfo[playerid][pSong][1], PlayerInfo[playerid][pSong][2], PlayerInfo[playerid][pNumber], PlayerInfo[playerid][pSpeakerPhone], PlayerInfo[playerid][pPB], PlayerInfo[playerid][pPhonePrivacy]);
    format(szQuery, sizeof(szQuery), "%s, JobID = '%d', JobID2 = '%d', MechTime = '%d', DetSkill = '%d', DrugsSkill = '%d', SmugSkill = '%d'", szQuery, PlayerInfo[playerid][pJobID], PlayerInfo[playerid][pJobID2], PlayerInfo[playerid][pMechTime], PlayerInfo[playerid][pDetSkill], PlayerInfo[playerid][pDrugsSkill], PlayerInfo[playerid][pSmugSkill]);
    format(szQuery, sizeof(szQuery), "%s, ArmsSkill = '%d', LawSkill = '%d', TruckSkill = '%d', MechSkill = '%d', FishSkill = '%d', TraderPerk = '%d'", szQuery, PlayerInfo[playerid][pArmsSkill], PlayerInfo[playerid][pLawSkill], PlayerInfo[playerid][pTruckSkill], PlayerInfo[playerid][pMechSkill], PlayerInfo[playerid][pFishSkill], PlayerInfo[playerid][pTraderPerk]);
    format(szQuery, sizeof(szQuery), "%s, Skin = '%d', Team = '%d', Accent = '%d', Admin = '%d', Helper = '%d', DutyHours = '%d', AcceptedHelp = '%d'", szQuery, PlayerInfo[playerid][pSkin], PlayerInfo[playerid][pTeam], PlayerInfo[playerid][pAccent], PlayerInfo[playerid][pAdmin], PlayerInfo[playerid][pHelper], PlayerInfo[playerid][pDutyHours], PlayerInfo[playerid][pAcceptedHelp]);
    format(szQuery, sizeof(szQuery), "%s, Spectate = '%d', Banned = '%d', PermaBanned = '%d', LiveBanned = '%d', Muted = '%d', ReportMuted = '%d'", szQuery, PlayerInfo[playerid][pSpectate], PlayerInfo[playerid][pBanned], PlayerInfo[playerid][pPermaBanned], PlayerInfo[playerid][pLiveBanned], PlayerInfo[playerid][pMuted], PlayerInfo[playerid][pReportMuted]);
    format(szQuery, sizeof(szQuery), "%s, Exp = '%d', VIP = '%d', VMuted = '%d', Jailed = '%d', JailTime = '%d', BeingSentenced = '%d'", szQuery, PlayerInfo[playerid][pExp], PlayerInfo[playerid][pVIP], PlayerInfo[playerid][pVMuted], PlayerInfo[playerid][pJailed], PlayerInfo[playerid][pJailTime], PlayerInfo[playerid][pBeingSentenced]);
    format(szQuery, sizeof(szQuery), "%s, ProbationTime = '%d', PrisonReason = '%s', PrisonedBy = '%s', BannedReason = '%s', BannedBy = '%s'", szQuery, PlayerInfo[playerid][pProbationTime], PlayerInfo[playerid][pPrisonReason], PlayerInfo[playerid][pPrisonedBy], PlayerInfo[playerid][pBannedReason], PlayerInfo[playerid][pBannedBy]);
    format(szQuery, sizeof(szQuery), "%s, ToggedVIPChat = '%d', Warns = '%d', GangWarn = '%d', Pos_x = '%f', Pos_y = '%f', Pos_z = '%f'", szQuery, PlayerInfo[playerid][pToggedVIPChat], PlayerInfo[playerid][pWarns], PlayerInfo[playerid][pGangWarn], PlayerInfo[playerid][pPos_x], PlayerInfo[playerid][pPos_y], PlayerInfo[playerid][pPos_z]);
    format(szQuery, sizeof(szQuery), "%s, Pos_a = '%f', Health = '%f', Armor = '%f', SHealth = '%f', SArmor = '%f', Materials = '%d'", szQuery, PlayerInfo[playerid][pPos_a], PlayerInfo[playerid][pHealth], PlayerInfo[playerid][pArmor], PlayerInfo[playerid][pSHealth], PlayerInfo[playerid][pSArmor], PlayerInfo[playerid][pMaterials]);
    format(szQuery, sizeof(szQuery), "%s, Cocaine = '%d', Fishes = '%d', BiggestFish = '%d', Crates = '%d', INT = '%d', VW = '%d', Dice = '%d'", szQuery, PlayerInfo[playerid][pCocaine], PlayerInfo[playerid][pFishes], PlayerInfo[playerid][pBiggestFish], PlayerInfo[playerid][pCrates], PlayerInfo[playerid][pINT], PlayerInfo[playerid][pVW], PlayerInfo[playerid][pDice]);
    for(new i = 0; i < 11; i++)
    {
        format(szQuery, sizeof(szQuery), "%s, Weapon%d = '%d'", szQuery, i, PlayerInfo[playerid][pWeapon][i]);
        format(szQuery, sizeof(szQuery), "%s, Weapona%d = '%d'", szQuery, i, PlayerInfo[playerid][pWeapona][i]);
    }
    format(szQuery, sizeof(szQuery), "%s, KillLog0 = '%s', KillLog1 = '%s', KillLog2 = '%s', KillLog3 = '%s', KillLog4 = '%s', KillLog5 = '%s'", szQuery, PlayerInfo[playerid][pKillLog0], PlayerInfo[playerid][pKillLog1], PlayerInfo[playerid][pKillLog2], PlayerInfo[playerid][pKillLog3], PlayerInfo[playerid][pKillLog4], PlayerInfo[playerid][pKillLog5]);
    format(szQuery, sizeof(szQuery), "%s, KillLog6 = '%s', KillLog7 = '%s', KillLog8 = '%s', KillLog9 = '%s', Deaths = '%d', Faction = '%d'", szQuery, PlayerInfo[playerid][pKillLog6], PlayerInfo[playerid][pKillLog7], PlayerInfo[playerid][pKillLog8], PlayerInfo[playerid][pKillLog9], PlayerInfo[playerid][pDeaths], PlayerInfo[playerid][pFaction]);
    format(szQuery, sizeof(szQuery), "%s, GangID = '%d', GangRank = '%d', BeingInvitedToGang = '%d', Rank = '%d', Division = '%d', Leader = '%d'", szQuery, PlayerInfo[playerid][pGangID], PlayerInfo[playerid][pGangRank], PlayerInfo[playerid][pBeingInvitedToGang], PlayerInfo[playerid][pRank], PlayerInfo[playerid][pDivision], PlayerInfo[playerid][pLeader]);
    format(szQuery, sizeof(szQuery), "%s, Married = '%d', MarriedTo = '%s', Duty = '%d', JobDuty = '%d', Crimes = '%d', WantedLevel = '%d'", szQuery, PlayerInfo[playerid][pMarried], PlayerInfo[playerid][pMarriedTo], PlayerInfo[playerid][pDuty], PlayerInfo[playerid][pJobDuty], PlayerInfo[playerid][pCrimes], PlayerInfo[playerid][pWantedLevel]);
    format(szQuery, sizeof(szQuery), "%s, Radio = '%d', RadioFreq = '%d', Wristwatch = '%d', Blindfold = '%d', Rope = '%d', Dashboard = '%d'", szQuery, PlayerInfo[playerid][pRadio], PlayerInfo[playerid][pRadioFreq], PlayerInfo[playerid][pWristwatch], PlayerInfo[playerid][pBlindfold], PlayerInfo[playerid][pRope], PlayerInfo[playerid][pDashboard]);
    format(szQuery, sizeof(szQuery), "%s, Speedo = '%d', Phousekey = '%d', Phousekey2 = '%d', Renting = '%d', RefPoints = '%d', RefPlayer = '%s'", szQuery, PlayerInfo[playerid][pSpeedo], PlayerInfo[playerid][pPhousekey], PlayerInfo[playerid][pPhousekey2], PlayerInfo[playerid][pRenting], PlayerInfo[playerid][pRefPoints], PlayerInfo[playerid][pRefPlayer]);
    format(szQuery, sizeof(szQuery), "%s, HSpawn = '%d', HSpawnX = '%f', HSpawnY = '%f', HSpawnZ = '%f', HSpawnInt = '%d', HSpawnVW = '%d'", szQuery, PlayerInfo[playerid][pHSpawn], PlayerInfo[playerid][pHSpawnX], PlayerInfo[playerid][pHSpawnY], PlayerInfo[playerid][pHSpawnZ], PlayerInfo[playerid][pHSpawnInt], PlayerInfo[playerid][pHSpawnVW]);
    format(szQuery, sizeof(szQuery), "%s, Biz = '%d', VBiz = '%d', RequestingBackup = '%d', AttendingBackupCall = '%d', Bugged = '%d'", szQuery, PlayerInfo[playerid][pBiz], PlayerInfo[playerid][pVBiz], PlayerInfo[playerid][pRequestingBackup], PlayerInfo[playerid][pAttendingBackupCall], PlayerInfo[playerid][pBugged]);
    format(szQuery, sizeof(szQuery), "%s, HeadValue = '%d', ContractBy = '%s', ContractDetail = '%s', C4Used = '%d', C4 = '%d', Bombs = '%d'", szQuery, PlayerInfo[playerid][pHeadValue], PlayerInfo[playerid][pContractBy], PlayerInfo[playerid][pContractDetail], PlayerInfo[playerid][pC4Used], PlayerInfo[playerid][pC4], PlayerInfo[playerid][pBombs]);
    format(szQuery, sizeof(szQuery), "%s, CHits = '%d', FHits = '%d', AcceptReport = '%d', TrashReport = '%d', Spraycan = '%d', Boombox = '%d'", szQuery, PlayerInfo[playerid][pCHits], PlayerInfo[playerid][pFHits], PlayerInfo[playerid][pAcceptReport], PlayerInfo[playerid][pTrashReport], PlayerInfo[playerid][pSpraycan], PlayerInfo[playerid][pBoombox]);
    format(szQuery, sizeof(szQuery), "%s, BoomboxOwned = '%d', BankPIN = '%d', BankPINReset = '%d', Lock = '%d', LockCar = '%d', GasCan = '%d'", szQuery, PlayerInfo[playerid][pBoomboxOwned], PlayerInfo[playerid][pBankPIN], PlayerInfo[playerid][pBankPINReset], PlayerInfo[playerid][pLock], PlayerInfo[playerid][pLockCar], PlayerInfo[playerid][pGasCan]);
    format(szQuery, sizeof(szQuery), "%s, Firstaid = '%d', Sprunk = '%d', Cigar = '%d', Crack = '%d', Pot = '%d', DrugsTime = '%d', LawyerTime = '%d'", szQuery, PlayerInfo[playerid][pFirstaid], PlayerInfo[playerid][pSprunk], PlayerInfo[playerid][pCigar], PlayerInfo[playerid][pCrack], PlayerInfo[playerid][pPot], PlayerInfo[playerid][pDrugsTime], PlayerInfo[playerid][pLawyerTime]);
    format(szQuery, sizeof(szQuery), "%s, WExists = '%d', WX = '%f, WY = '%f', WZ = '%f', WVW = '%d', WInt = '%d', WValue = '%d', WSeeds = '%d'", szQuery, PlayerInfo[playerid][pWExists], PlayerInfo[playerid][pWX], PlayerInfo[playerid][pWY], PlayerInfo[playerid][pWZ], PlayerInfo[playerid][pWVW], PlayerInfo[playerid][pWInt], PlayerInfo[playerid][pWValue], PlayerInfo[playerid][pWSeeds]);
    format(szQuery, sizeof(szQuery), "%s, WObject = '%d', WTimer = '%d', CarLic = '%d', FlyLic = '%d', BoatLic = '%d', WeaponLic = '%d'", szQuery, PlayerInfo[playerid][pWObject], PlayerInfo[playerid][pWTimer], PlayerInfo[playerid][pCarLic], PlayerInfo[playerid][pFlyLic], PlayerInfo[playerid][pBoatLic], PlayerInfo[playerid][pWeaponLic]);
    format(szQuery, sizeof(szQuery), "%s, Tutorial = '%d', TutorialStep = '%d', TutorialStepDelay = '%d', FightStyle = '%d', Insurance = '%d', Hospital = '%d'", szQuery, PlayerInfo[playerid][pTutorial], PlayerInfo[playerid][pTutorialStep], PlayerInfo[playerid][pTutorialStepDelay], PlayerInfo[playerid][pFightStyle], PlayerInfo[playerid][pInsurance], PlayerInfo[playerid][pHospital]);
    format(szQuery, sizeof(szQuery), "%s, NMute = '%d', NMuteTotal = '%d', ADMute = '%d', ADMuteTotal = '%d', Flag = '%s', IP = '%s'", szQuery, PlayerInfo[playerid][pNMute], PlayerInfo[playerid][pNMuteTotal], PlayerInfo[playerid][pADMute], PlayerInfo[playerid][pADMuteTotal], PlayerInfo[playerid][pFlag], PlayerInfo[playerid][pIP]);
    format(szQuery, sizeof(szQuery), "%s, Status = %d WHERE ID = %d", szQuery, PlayerInfo[playerid][pStatus], PlayerInfo[playerid][pDBID]);

    mysql_query(szQuery, THREAD_NO_RESULT, playerid, iConnectionHandle);

    return 1;
}
Error I get in console:

Quote:

[15:32:33] Error #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 ''' at line 1 | Query: UPDATE players SET Cash = '600', Deposit = '3000', CreditCard = '0', PayDay = '0', PayCheck = '0', ConnectTime = '0', WRestricted = '2', Age = '21', Sex = '0', Level = '0', HasCellphone = '0', Internet = '0', Song1 = '0', Song2 = '0', Number = '0', SpeakerPhone = '0', PB = '0' , PhonePrivacy = '0', JobID = '0', JobID2 = '0', MechTime = '0', DetSkill = '0', DrugsSkill = '0', SmugSkill = '0', ArmsSkill = '0', LawSkill = '0', TruckSkill = '0', MechSkill = '0', FishSkill = '0', TraderPerk = '0', Skin = '299', Team = '0', Accent = '0', Admin = '0', Helper = '0', DutyHours = '0', AcceptedHelp = '0', Spectate = '0', Banned = '0', PermaBanned = '0', LiveBanned = '0', Muted = '0', ReportMuted = '0', Exp = '0', VIP = '0', VMuted = '0', Jailed = '0', JailTime = '0', BeingSentenced = '0', ProbationTime = '0', PrisonReason = 'None', PrisonedBy = 'None', BannedReason = 'None', BannedBy = 'None', ToggedVIPChat = '0', Warns = '0', GangWarn = '0', Pos_x = '1668.943237', Pos_y = '-1458.119750', Pos_z = '120.611900', Pos_a = '

Note: I'm new to MySQL; Base Script (Well, MySQL part) = https://sampforum.blast.hk/showthread.php?tid=344978

Another note: string = szQuery - I just refer to it as string.
Reply


Messages In This Thread
MySQL save problem (BIG string) - by ryansheilds - 24.06.2012, 11:43
Re: MySQL save problem (BIG string) - by Grand_Micha - 24.06.2012, 11:54
Re: MySQL save problem (BIG string) - by ryansheilds - 24.06.2012, 12:09
Re: MySQL save problem (BIG string) - by iggy1 - 24.06.2012, 12:30
Re: MySQL save problem (BIG string) - by ryansheilds - 24.06.2012, 12:40
Re: MySQL save problem (BIG string) - by iggy1 - 24.06.2012, 12:47
Re: MySQL save problem (BIG string) - by ryansheilds - 24.06.2012, 12:58
Re: MySQL save problem (BIG string) - by ryansheilds - 24.06.2012, 21:02
Re: MySQL save problem (BIG string) - by Badger(new) - 24.06.2012, 21:28
Re: MySQL save problem (BIG string) - by ryansheilds - 24.06.2012, 21:53

Forum Jump:


Users browsing this thread: 2 Guest(s)