SQL SAVing
#1

what's wrong with it?

PHP код:
forward OnPlayerSave(playerid);
public 
OnPlayerSave(playerid)
{
    new 
query[500];
    if(
IsLoggedIn[playerid] == && playerid != INVALID_PLAYER_ID && !IsPlayerNPC(playerid))
    {
        
strcat(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,");
        
strcat(query"`Crimes`=%d, `WantedLevel`=%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][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

Okay aight after doing this.

PHP код:
5593) : error 001expected token"-string end-"but found "-identifier-"
(5593) : error 017undefined symbol "players"
 
(5593): warning 215expression has no effect
5593
) : error 001expected token";"but found ")"
(5593) : fatal error 107too many error messages on one line 
PHP код:
forward OnPlayerSave(playerid);
public 
OnPlayerSave(playerid)
{
    new 
query[500];
    if(
IsLoggedIn[playerid] == && playerid != INVALID_PLAYER_ID && !IsPlayerNPC(playerid))
    {
        
strcat(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',");
        
strcat(query"Crimes ='%d', WantedLevel ='%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][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
#3

What about this?:

pawn Код:
if(pInfo[playerid][pAdmin] >= 1)
        {
            mysql_format(MySQLCon, query, sizeof(query), "UPDATE `players` SET `AdminName`=%s WHERE `ID`=%d AND `user`='%e'", pInfo[playerid][pAName]);
            return true;
        }
you basically do not send this just format the string!
Reply
#4

Nah. The problem is on line 5593

Which is
PHP код:
strcat(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',"); 
Reply
#5

need it urgent pls some1 help
Reply
#6

Im still stuck on this. Anyone help me? I would be your thankful.
Reply
#7

Why do you have players in " marks? `players`
Reply
#8

Well, I changed into this

PHP код:
///mysql start
forward OnPlayerSave(playerid);
public 
OnPlayerSave(playerid)
{
    new 
query[500];
    new 
tmp[64];
    if(
IsLoggedIn[playerid] == && playerid != INVALID_PLAYER_ID && !IsPlayerNPC(playerid))
    {
        
formatquerysizeofquery ), "UPDATE `players` SET " );
        
        
formattmpsizeoftmp ), "`Admin`=%d, "pInfo[playerid][pAdmin]);
        
strcatquerytmp );
        
        
formattmpsizeoftmp ), "`Vip`=%d, "pInfo[playerid][pVip]);
        
strcatquerytmp );
        
        
formattmpsizeoftmp ), "`Money`=%d, "GetPlayerCash(playerid));
        
strcatquerytmp );
        
        
formattmpsizeoftmp ), "`Deaths`=%d, "pInfo[playerid][pDeaths]);
        
strcatquerytmp );
        
        
formattmpsizeoftmp ), "`Kills`=%d, "pInfo[playerid][pKills]);
        
strcatquerytmp );
        
        
formattmpsizeoftmp ), "`HitsCompleted`=%d, "pInfo[playerid][pHitsCompleted]);
        
strcatquerytmp );
        
        
formattmpsizeoftmp ), "`SkinID`=%d, "pInfo[playerid][pDeaths]);
        
strcatquerytmp );
        
        
formattmpsizeoftmp ), "`Robbed`=%d, "pInfo[playerid][pRobbed]);
        
strcatquerytmp );

        
formattmpsizeoftmp ), "`RobbedMoney`=%d, "pInfo[playerid][pRobbedMoney]);
        
strcatquerytmp );
        
        
formattmpsizeoftmp ), "`GotRobbed`=%d, "pInfo[playerid][pGotRobbed]);
        
strcatquerytmp );
        
        
formattmpsizeoftmp ), "`GotRobbedMoney`=%d, "pInfo[playerid][pGotRobbedMoney]);
        
strcatquerytmp );
        
        
formattmpsizeoftmp ), "`StoreRobbed`=%d, "pInfo[playerid][pStoreRobbed]);
        
strcatquerytmp );
        
        
formattmpsizeoftmp ), "`StoreRobbedMoney`=%d, "pInfo[playerid][pStoreRobbedMoney]);
        
strcatquerytmp );
        
        
formattmpsizeoftmp ), "`FoodPurchased`=%d, "pInfo[playerid][pFoodPurchased]);
        
strcatquerytmp );
        
        
formattmpsizeoftmp ), "`FoodPurchasedMoney`=%d, "pInfo[playerid][pFoodPurchasedMoney]);
        
strcatquerytmp );
        
        
formattmpsizeoftmp ), "`WeaponsPurchased`=%d, "pInfo[playerid][pWeaponsPurchased]);
        
strcatquerytmp );
        
        
formattmpsizeoftmp ), "`WeaponsPurchasedMoney`=%d, "pInfo[playerid][pWeaponsPurchasedMoney]);
        
strcatquerytmp );
        
        
formattmpsizeoftmp ), "`Healed`=%d, "pInfo[playerid][pHealed]);
        
strcatquerytmp );
        
        
formattmpsizeoftmp ), "`Arrest`=%d, "pInfo[playerid][pArrest]);
        
strcatquerytmp );
        
        
formattmpsizeoftmp ), "`Busted`=%d, "pInfo[playerid][pBusted]);
        
strcatquerytmp );
        
        
formattmpsizeoftmp ), "`Crimes`=%d, "pInfo[playerid][pCrimes]);
        
strcatquerytmp );
        
        
formattmpsizeoftmp ), "`WantedLevel`=%d, "pInfo[playerid][pWantedLevel]);
        
strcatquerytmp );
        
        
formattmpsizeoftmp ), "`Drugs`=%d, "pInfo[playerid][pDrugs]);
        
strcatquerytmp );
        
        
formattmpsizeoftmp ), "`Medical`=%d, "pInfo[playerid][pMedical]);
        
strcatquerytmp );
        
        
formattmpsizeoftmp ), "`Drugs`=%d, "pInfo[playerid][pDrugs]);
        
strcatquerytmp );
        
        
formattmpsizeoftmp ), "WHERE `ID`= %d AND `user`= '%e'"pInfo[playerid][pID], PlayerName(playerid));
        
strcatquerytmp );
        
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;

But this doesn't update my database.
Reply
#9

Someone help me? I have been asking for help from yesterday? Rly Nobody wants to help me?
Reply
#10

Quote:
Originally Posted by STONEGOLD
Посмотреть сообщение
Nah. The problem is on line 5593

Which is
PHP код:
strcat(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',"); 

simply put...
You're referencing completely wrong....

INCORRECT CODE
PHP код:
strcat(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',"); 
CORRECT CODE
PHP код:
strcat(query"UPDATE `players` SET `Admin` = %d, `Vip` = %d, `Money` = %d 
PLEASE NOTE
IF You're REFERENCING A STRING.....
PHP код:
"UPDATE `players` SET `username` = '%s' 
SQL Syntax doesn't require nor accept quotations around an integer.. ONLY A string / variable with characters.

So...

%d would be %d when referenced via SQL
%s would be '%s' when referenced via SQL
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)