MYSQL SAVING ERROR (NEED IT URGENT) Thanks!
#1

Well, I added more in saving system of mysql but it says The line is too long.

Here you can see the code. It says the ling is too long so then i tried something new but got error. So, I wanted to post it here cuz i want get something best from pro scripters. Thanks.

PHP Code:
///mysql start
forward OnPlayerSave(playerid);
public 
OnPlayerSave(playerid)
{
    new 
query[500];
    if(
IsLoggedIn[playerid] == && playerid != INVALID_PLAYER_ID && !IsPlayerNPC(playerid))
    {
        
mysql_format(MySQLConquerysizeof(query), "UPDATE `players` SET `Admin`=%d, `Vip`=%d, `Money`=%d, `Score`=%d, `Deaths`=%d, `Kills`=%d, `HitsCompleted`=%d, `SkinID`=%d, `Robbed`=%d, `RobbedMoney`=%d, `GotRobbed`=%d, `GotRobbedMoney`=%d, `StoreRobbed`=%d, `StoreRobbedMoney`=%d, `FoodPurchased`=%d, `FoodPurchasedMoney`=%d, `WeaponsPurchased`=%d, `WeaponsPurchasedMoney`=%d, `Healed`=%d, `Arrest`=%d, `Busted`=%d, `Crimes`=%d, `WantedLevel`=%d, `Drugs`=%d, `Medical`=%d WHERE `ID`=%d AND `user`='%e'",
        
pInfo[playerid][pAdmin],
        
pInfo[playerid][pVip],
        
GetPlayerMoney(playerid),
        
GetPlayerScore(playerid),
        
pInfo[playerid][pDeaths],
        
pInfo[playerid][pKills],
        
pInfo[playerid][pHitsCompleted],
        
GetPlayerSkin(playerid),
        
pInfo[playerid][pRobbed],
        
pInfo[playerid][pRobbedMoney],
        
pInfo[playerid][pGotRobbed],
        
pInfo[playerid][pGotRobbedMoney],
        
pInfo[playerid][pStoreRobbed],
        
pInfo[playerid][pStoreRobbedMoney],
        
pInfo[playerid][pFoodPurchased],
        
pInfo[playerid][pFoodPurchasedMoney],
        
pInfo[playerid][pWeaponsPurchased],
        
pInfo[playerid][pWeaponsPurchasedMoney],
        
pInfo[playerid][pHealed],
        
pInfo[playerid][pArrest],
        
pInfo[playerid][pBusted],
        
pInfo[playerid][pCrimes],
        
pInfo[playerid][pWantedLevel],
        
pInfo[playerid][pDrugs],
        
pInfo[playerid][pMedical],
        
pInfo[playerid][pID],
        
PlayerName(playerid));
        
mysql_tquery(MySQLConquery"""");
        print(
query);
        
mysql_format(MySQLConquerysizeof(query), "UPDATE `players` SET `IsBanned`=%d WHERE `ID`=%d AND user='%e'"pInfo[playerid][pIsBanned], PlayerName(playerid));
        
mysql_tquery(MySQLConquery"""");
        
IsLoggedIn[playerid] = 0;
        if(
pInfo[playerid][pAdmin] >= 1)
        {
            
mysql_format(MySQLConquerysizeof(query), "UPDATE `players` SET `AdminName`=%s WHERE `ID`=%d AND `user`='%e'"pInfo[playerid][pAName]);
            return 
true;
        }
    }
    return 
1;

PHP Code:
5475) : error 075input line too long (after substitutions
Then i tried this tho it would work but didn't work still got error and i think it's wrong. Do you have any idea?

PHP Code:
forward OnPlayerSave(playerid);
public 
OnPlayerSave(playerid)
{
    new 
query[500];
    if(
IsLoggedIn[playerid] == && playerid != INVALID_PLAYER_ID && !IsPlayerNPC(playerid))
    {
        
mysql_format(MySQLConquerysizeof(query), "UPDATE `players` SET `Admin`=%d, `Vip`=%d, `Money`=%d, `Score`=%d, `Deaths`=%d, `Kills`=%d, `HitsCompleted`=%d, `SkinID`=%d, `Robbed`=%d, `RobbedMoney`=%d, `GotRobbed`=%d, `GotRobbedMoney`=%d, `StoreRobbed`=%d, `StoreRobbedMoney`=%d, `FoodPurchased`=%d, `FoodPurchasedMoney`=%d, `WeaponsPurchased`=%d, `WeaponsPurchasedMoney`=%d, `Healed`=%d, `Arrest`=%d, `Busted`=%d, `Crimes`=%d, `WantedLevel`=%d, `Drugs`=%d, \
        `Medical`=%d WHERE `ID`=%d AND `user`='%e'"
,
        
pInfo[playerid][pAdmin],
        
pInfo[playerid][pVip],
        
GetPlayerMoney(playerid),
        
GetPlayerScore(playerid),
        
pInfo[playerid][pDeaths],
        
pInfo[playerid][pKills],
        
pInfo[playerid][pHitsCompleted],
        
GetPlayerSkin(playerid),
        
pInfo[playerid][pRobbed],
        
pInfo[playerid][pRobbedMoney],
        
pInfo[playerid][pGotRobbed],
        
pInfo[playerid][pGotRobbedMoney],
        
pInfo[playerid][pStoreRobbed],
        
pInfo[playerid][pStoreRobbedMoney],
        
pInfo[playerid][pFoodPurchased],
        
pInfo[playerid][pFoodPurchasedMoney],
        
pInfo[playerid][pWeaponsPurchased],
        
pInfo[playerid][pWeaponsPurchasedMoney],
        
pInfo[playerid][pHealed],
        
pInfo[playerid][pArrest],
        
pInfo[playerid][pBusted],
        
pInfo[playerid][pCrimes],
        
pInfo[playerid][pWantedLevel],
        
pInfo[playerid][pDrugs],
        
pInfo[playerid][pMedical],
        
pInfo[playerid][pID],
        
PlayerName(playerid));
        
mysql_tquery(MySQLConquery"""");
        print(
query);
        
mysql_format(MySQLConquerysizeof(query), "UPDATE `players` SET `IsBanned`=%d WHERE `ID`=%d AND user='%e'"pInfo[playerid][pIsBanned], PlayerName(playerid));
        
mysql_tquery(MySQLConquery"""");
        
IsLoggedIn[playerid] = 0;
        if(
pInfo[playerid][pAdmin] >= 1)
        {
            
mysql_format(MySQLConquerysizeof(query), "UPDATE `players` SET `AdminName`=%s WHERE `ID`=%d AND `user`='%e'"pInfo[playerid][pAName]);
            return 
true;
        }
    }
    return 
1;

Reply
#2

I think Zeex's compiler patches fixed that: https://github.com/Zeex/pawn
Reply
#3

Oh! Thanks bro. But any idea how to fix it in this pwno?
Reply
#4

Split it up in different queries, like you did with the banned data. Note that, that does not work with 'INSERT INTO' though.
Reply
#5

I used that "technique" to build long query strings:

PHP Code:
new query[1024]; // long string with sql query
new tmp[64];
formatquery1024"UPDATE players SET " );
formattmp64"age = %i, "player[playerid][AGE] );
strcatquerytmp );
formattmp64"health = %0.2f, "player[playerid][HEALTH] );
strcatquerytmp );
// ...
formattmp64"money = %i "player[playerid][MONEY] );
strcatquerytmp );
formattmp64"WHERE id = %i;"player[playerid][BASEID] );
strcatquerytmp );
mysql_querymysqlquery ); 
Reply
#6

Oh! Yeah i have searched on forum and got this method. But I want to know from a good scripters is it good if i use like this? But I would like to have a solution in my method. Anyone?
Reply
#7

Quote:
Originally Posted by STONEGOLD
View Post
Oh! Yeah i have searched on forum and got this method. But I want to know from a good scripters is it good if i use like this? But I would like to have a solution in my method. Anyone?
What you mean saying "good"?
Maybe in case of very large query in will be 1-2ms slower than using one format() up to 512 characters. I use that for my life and never got any problems.

Good:
+ You can create very large queries without reaching 512 char line limit
+ Everything is clear, you will probably never make a mistake in format() arguments order
+ It's the only way to format a big query and to execute it without splitting into smaller ones
+ Mysql server executes only one query - it's a big +

Bad:
- It uses +64 cells of memory for tmp var
- Someone suggested not to create long strings, but I think that a frw bytes of wasted memory is better than ten Mysql queries.
Reply
#8

AH thanks, Can you make it like this. I want to see how does it look like so i can code it

PHP Code:
forward OnPlayerSave(playerid); 
public 
OnPlayerSave(playerid

    new 
query[500]; 
    if(
IsLoggedIn[playerid] == && playerid != INVALID_PLAYER_ID && !IsPlayerNPC(playerid)) 
    { 
        
mysql_format(MySQLConquerysizeof(query), "UPDATE `players` SET `Admin`=%d, `Vip`=%d, `Money`=%d, `Score`=%d, `Deaths`=%d, `Kills`=%d, `HitsCompleted`=%d, `SkinID`=%d, `Robbed`=%d, `RobbedMoney`=%d, `GotRobbed`=%d, `GotRobbedMoney`=%d, `StoreRobbed`=%d, `StoreRobbedMoney`=%d, `FoodPurchased`=%d, `FoodPurchasedMoney`=%d, `WeaponsPurchased`=%d, `WeaponsPurchasedMoney`=%d, `Healed`=%d, `Arrest`=%d, `Busted`=%d, `Crimes`=%d, `WantedLevel`=%d, `Drugs`=%d, \ 
        `Medical`=%d WHERE `ID`=%d AND `user`='%e'"

        
pInfo[playerid][pAdmin], 
        
pInfo[playerid][pVip], 
        
GetPlayerMoney(playerid), 
        
GetPlayerScore(playerid), 
        
pInfo[playerid][pDeaths], 
        
pInfo[playerid][pKills], 
        
pInfo[playerid][pHitsCompleted], 
Just make it look like this for exmaple. Thanks!
Reply
#9

BUmp
Reply
#10

How many times I have to say it? Do not save everything at once if you can help it. How often does the admin level change? Or the VIP level? Or ...? Once per year or so? What good does it do updating something that hasn't changed?

Update stuff when it changes and you will have far more concise queries and less troubles.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)