mysql saving error
#1

It's not saving. It comes up saying: "[11:41:42] [ERROR] mysql_format - no value for specifier "%e" available" in the mysql_log.

Anybody sees the error?

pawn Код:
format(gVar3000, 3000, "%s", EOS);
            strcat(gVar3000, "UPDATE `samp_users` SET `walkstyle` = %i, `chatstyle` = %i, `gender` = %i, `age` = %i, `skin` = %i, `adminlevel` = %i, `money` = %i, ");
            strcat(gVar3000, "`renthouse` = %i, `ip` = '%e', `score` = %i, `faction` = %i, `rank` = %i, `arresttime` = %i, `spawnLoc` = %i, `radioobj` = %i, ");
            strcat(gVar3000, "`badge` = %i, `drivelic` = %i, `bank` = %i, `pAJCPs` = %i, `weaponlic` = %i, `fish` = %i, `job` = %i, `modlevel` = %i, ");
            strcat(gVar3000, "`paycheck` = %i, `jobtime` = %i, `PayTimer` = %i, `pForumName` = '%e', `pDisX` = %f, `pDisY` = %f, `pDisZ` = %f, `pDisA` = %f, `pDisInt` = %i, ");
            strcat(gVar3000, "`pDisVW` = %i, `health` = %f, `armour` = %f, `pTrainticket` = %i, `pFine` = %i, `pSavings` = %i, `pTaxiLic` = %i, `pAirplaneLic` = %i, `duty` = %i, ");
            strcat(gVar3000, "`namechanges` = %i, `weed` = %i, `cocaine` = %i, `ecstasy` = %i, `crack` = %i, `heroin` = %i, `weed-seeds` = %i, `opium-seeds` = %i, ");
            strcat(gVar3000, "`fertilizer` = %i, `raw-opium` = %i, `cuffed` = %i, `donate-rank` = %i, `donate-year` = %i, `donate-month` = %i, `donate-day` = %i, ");
            strcat(gVar3000, "`carbomb` = %i, `scrap-wait` = %i, `loaned` = %i, `loancash` = %i, `maskID` = %i, `prisoned` = %i, `prison-time` = %i,");
            strcat(gVar3000, "`swat` = %i, `swat-cooldown` = %i, `weed-a` = %i, `coke-a` = %i, `ecstasy-a` = %i, `crack-a` = %i, `heroin-a` = %i, `freq` = %i, ");
            strcat(gVar3000, "`activated` = %i, `pBanAppealer` = %i, `pPR` = %i, `pHR` = %i, `pAP` = %i, `pSecurity` = %i, `pShopTech` = %i, `pFactionModerator` = %i WHERE user = '%e'");
           
            mysql_format(sqlHandle, gVar3000, sizeof(gVar3000), gVar3000, PlayerInfo[playerid][pWalkstyle], PlayerInfo[playerid][pChatstyle], PlayerInfo[playerid][pGender], PlayerInfo[playerid][pAge],
                                                      skin, PlayerInfo[playerid][pAdminlevel], PlayerInfo[playerid][pMoney], PlayerInfo[playerid][pRentHouse],
                                                      PlayerInfo[playerid][pIP], PlayerInfo[playerid][pScore], faction, PlayerInfo[playerid][pRank], GetPVarInt(playerid, "Arrest"), spawnLoc,
                                                      PlayerInfo[playerid][pRadio], PlayerInfo[playerid][pBadge], PlayerInfo[playerid][pDriveLic],
                                                      PlayerInfo[playerid][pBank], PlayerInfo[playerid][pAJCPs], PlayerInfo[playerid][pWeaponLic], PlayerInfo[playerid][pFish],
                                                      PlayerInfo[playerid][pJob], PlayerInfo[playerid][pModLevel], PlayerInfo[playerid][pPaycheck], PlayerInfo[playerid][pJobTime],
                                                      PlayerInfo[playerid][pPayTimer], PlayerInfo[playerid][pForumName], X, Y, Z, A, interior, virtualWorld, health,
                                                      armour, PlayerInfo[playerid][pTrainticket], PlayerInfo[playerid][pFine], PlayerInfo[playerid][pSavings], PlayerInfo[playerid][pTaxiLic],
                                                      PlayerInfo[playerid][pAirplaneLic], duty, PlayerInfo[playerid][pNamechanges], PlayerInfo[playerid][pWeed], PlayerInfo[playerid][pCocaine],
                                                      PlayerInfo[playerid][pEcstasy], PlayerInfo[playerid][pCrack], PlayerInfo[playerid][pHeroin], PlayerInfo[playerid][pWeedSeeds],
                                                      PlayerInfo[playerid][pOpiumSeeds], PlayerInfo[playerid][pFertilizer], PlayerInfo[playerid][pRawOpium], PlayerInfo[playerid][pCuffed],
                                                      PlayerInfo[playerid][pDonateRank], PlayerInfo[playerid][pDonateYear], PlayerInfo[playerid][pDonateMonth], PlayerInfo[playerid][pDonateDay],
                                                      PlayerInfo[playerid][pCarBomb], PlayerInfo[playerid][pScrapWait], PlayerInfo[playerid][pLoaned], PlayerInfo[playerid][pLoanCash],
                                                      PlayerInfo[playerid][pMaskID], PlayerInfo[playerid][pPrisoned], PlayerInfo[playerid][pPrisonTime], PlayerInfo[playerid][pSWAT],
                                                      PlayerInfo[playerid][pSwatCooldown], PlayerInfo[playerid][pWeedAddiction], PlayerInfo[playerid][pCocaineAddiction],
                                                      PlayerInfo[playerid][pEcstasyAddiction], PlayerInfo[playerid][pCrackAddiction], PlayerInfo[playerid][pHeroinAddiction],
                                                      PlayerInfo[playerid][pFreq], PlayerInfo[playerid][pActivated], PlayerInfo[playerid][pBanAppealer], PlayerInfo[playerid][pPR],
                                                      PlayerInfo[playerid][pHR], PlayerInfo[playerid][pAP], PlayerInfo[playerid][pSecurity], PlayerInfo[playerid][pFactionModerator], PlayerInfo[playerid][pName]);

            mysql_function_query(sqlHandle, gVar3000, false, "", "");
Reply
#2

Why do you use one huge query to update all fields?
Just create separate queries to update the fields that need to be changed.

For example: a player earns money from doing something, like doing a job.
You should only update his money in such a case, not update ALL fields in his account, where 99% of them stays the same.

Or when the player makes a kill and you wanna save that.
Create a query to only update his kills in this case.

Or when his health changes, or his armour, only change these values instead of just calling this huge query.

It's a database that can handle these things easily (that's what databases do and what they are designed for), you're not dealing with files where you need to rewrite the file when 1 thing changes.

I can't imagine why you're updating his walkstyle for example, when he only buys a house or something, or completes a job.


And with many smaller queries, you're less likely to make mistakes such as this one.
Reply
#3

Quote:
Originally Posted by PowerPC603
Посмотреть сообщение
Why do you use one huge query to update all fields?
Just create separate queries to update the fields that need to be changed.

For example: a player earns money from doing something, like doing a job.
You should only update his money in such a case, not update ALL fields in his account, where 99% of them stays the same.

Or when the player makes a kill and you wanna save that.
Create a query to only update his kills in this case.

Or when his health changes, or his armour, only change these values instead of just calling this huge query.

It's a database that can handle these things easily (that's what databases do and what they are designed for), you're not dealing with files where you need to rewrite the file when 1 thing changes.

I can't imagine why you're updating his walkstyle for example, when he only buys a house or something, or completes a job.


And with many smaller queries, you're less likely to make mistakes such as this one.
This is quite bullshit, you want him send queries everytime he kills a player? That would use much resources & would cause lags when there are like 25+ players!
Reply
#4

I found out what the error was. It said it couldn't find the info for the %e, because the "name" was missing at the end... Well, another one was, so a definition was missing.
Reply
#5

Quote:
Originally Posted by ShivRp
Посмотреть сообщение
This is quite bullshit, you want him send queries everytime he kills a player? That would use much resources & would cause lags when there are like 25+ players!
Are you kidding me? MySQL was built to handle large amounts of data and if you use threaded queries it won't cause lag. Yet, this is once again a prime example of a non-normalized database. Everything in one table, because ... reasons. Now, this is purely hypothetical, but please stay with me.

A physical person can have one account (table: users). Each account can have multiple characters (table: characters). Each character can have multiple licenses (table: licenses). Each character can have multiple drug types (table: drugs). Each character can belong to multiple factions (table: factions). Each faction can have multiple cars (table: faction_cars). And so on and so forth.

Database design is something you need to think through very carefully. You may want to draw it out on a piece of paper first.
Reply
#6

Quote:
Originally Posted by ShivRp
Посмотреть сообщение
This is quite bullshit, you want him send queries everytime he kills a player? That would use much resources & would cause lags when there are like 25+ players!
Really?
To me, it seems he's using this huge query everytime something happens in this server, using even more resources and create even more lag.

Some player's money changes -> huge query to update everything.
Another player's score changes -> same huge query to update everything.
A third player changes his skin -> same huge query that updates everything.

While the same result can be done by 3 different and small queries:

Money changes -> update the money using a small query.
Score changes -> update the score using a second small query.
Skin changes -> update the skin using a third small query.

Who would get the best results and least lag?
The one using the same huge query for everything, or the one who uses many small queries to only update the fields that change, leaving all the rest out of his query?

There is really no need to update every field when only 1 value changes.

And yes, for every kill, he would need to send a query.
In case the player disconnects (timeout or whatever reason), or the server crashes, you get the least dataloss when you save everything at the moment it changes.
That's how big MMORPG servers save their data as well.
In fact, that's how EVERY server saves the data.

As soon as the data changes, use a query to store it in the database, using a query that only takes the fields that have changed.

How would you save it?
Once every half hour or so?
Alot can happen in half an hour.
He might do 15 missions, buy a house, kill 25 people, sell a car and buy a new one.
If the server crashes right before it's time to save the data, your player WILL lose everything he did in that half hour and will need to redo everything he did.
If it happens alot, he might just leave your server because of the frequent dataloss.
Reply
#7

Quote:
Originally Posted by PowerPC603
Посмотреть сообщение
Really?
To me, it seems he's using this huge query everytime something happens in this server, using even more resources and create even more lag.

Some player's money changes -> huge query to update everything.
Another player's score changes -> same huge query to update everything.
A third player changes his skin -> same huge query that updates everything.

While the same result can be done by 3 different and small queries:

Money changes -> update the money using a small query.
Score changes -> update the score using a second small query.
Skin changes -> update the skin using a third small query.

Who would get the best results and least lag?
The one using the same huge query for everything, or the one who uses many small queries to only update the fields that change, leaving all the rest out of his query?

There is really no need to update every field when only 1 value changes.

And yes, for every kill, he would need to send a query.
In case the player disconnects (timeout or whatever reason), or the server crashes, you get the least dataloss when you save everything at the moment it changes.
That's how big MMORPG servers save their data as well.
In fact, that's how EVERY server saves the data.

As soon as the data changes, use a query to store it in the database, using a query that only takes the fields that have changed.

How would you save it?
Once every half hour or so?
Alot can happen in half an hour.
He might do 15 missions, buy a house, kill 25 people, sell a car and buy a new one.
If the server crashes right before it's time to save the data, your player WILL lose everything he did in that half hour and will need to redo everything he did.
If it happens alot, he might just leave your server because of the frequent dataloss.
A better database structure (design) would make it perfect! Calm down m8

Quote:
Originally Posted by Vince
Посмотреть сообщение
Are you kidding me? MySQL was built to handle large amounts of data and if you use threaded queries it won't cause lag. Yet, this is once again a prime example of a non-normalized database. Everything in one table, because ... reasons. Now, this is purely hypothetical, but please stay with me.

A physical person can have one account (table: users). Each account can have multiple characters (table: characters). Each character can have multiple licenses (table: licenses). Each character can have multiple drug types (table: drugs). Each character can belong to multiple factions (table: factions). Each faction can have multiple cars (table: faction_cars). And so on and so forth.

Database design is something you need to think through very carefully. You may want to draw it out on a piece of paper first.
Yeah I agree
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)