why doesnt update in database
#1

Код:
CMD:getgift(playerid, params[]) {
	if(GiftBoxInfo[playerid][pGiftBoxOn] == 0) return SCM(playerid, -1, "Giftbox-ul nu este activ..");
    if(IsPlayerInRangeOfPoint(playerid, 5.0, GiftBoxInfo[playerid][pGiftBoxPosX], GiftBoxInfo[playerid][pGiftBoxPosY], GiftBoxInfo[playerid][pGiftBoxPosZ])) 
    {
		new rand = random(11); new zzString[128] = EOS;
		switch(rand) {
			case 0..5: {
				SCM(playerid, -1, "{008080}(GIFTBOX){FFFFFF}: Felicitari! Ai deschis giftbox-ul si ai castigat 10.000.000$.");
				GivePlayerCash(playerid, 10000000);
				Update(playerid, pCashx);
				mysql_format(SQL,zzString,sizeof(zzString),"UPDATE giftboxd SET `GiftBoxMoney`='%s'", GiftBoxInfo[playerid][pGiftBoxMoney]);
				mysql_tquery(SQL,zzString,"","");
			}
mysql_format(SQL,zzString,sizeof(zzString),"UPDATE giftboxd SET `GiftBoxMoney`='%s'", GiftBoxInfo[playerid][pGiftBoxMoney]);

this thing does not update in database, no errors in console..
Reply
#2

Quote:
Originally Posted by ******
Посмотреть сообщение
There's no `WHERE`.
i don t get it what to do :<
Reply
#3

Simply add a “WHERE” clause for the query to work properly.

PHP код:
UPDATE giftboxd SET `GiftBoxMoney`='%s' WHERE {something} = {something
Note that the “something” fields are for you to figure out what goes in their place.
Reply
#4

added WHERE `ID` but still nope..
Reply
#5

Код:
mysql_format(SQL,zzString,sizeof(zzString),"UPDATE `giftboxd` SET `GiftBoxMoney`='%s' WHERE `GiftBoxOn`='1'", GiftBoxInfo[playerid][pGiftBoxMoney], GiftBoxInfo[playerid][pGiftBoxOn]);
				mysql_tquery(SQL,zzString,"","");
Reply
#6

anyone please?
Reply
#7

Maybe you should start learning sql
Reply
#8

Post the giftbox enum, there should be a ID included. If so you can do it:

pawn Код:
mysql_format(SQL,zzString,sizeof(zzString),"UPDATE `giftboxd` SET `GiftBoxMoney`= '%s' WHERE `ID`= %i", GiftBoxInfo[playerid][pGiftBoxMoney], GiftBoxInfo[playerid][ID]);
    mysql_tquery(SQL,zzString);
Or else making sure it works:
pawn Код:
mysql_format(SQL,zzString,sizeof(zzString),"UPDATE `giftboxd` SET `GiftBoxMoney`= '%s' WHERE `ID`= %i", GiftBoxInfo[playerid][pGiftBoxMoney], GiftBoxInfo[playerid][ID]);
    mysql_tquery(SQL,zzString, "OnUpdateGiftBox", "i", GiftboxInfo[playerid][ID]);

    forward OnUpdateGiftBox(giftboxid);
    public OnUpdateGiftBox(giftboxid)
    {
        if(cache_affected_rows() > 0)
        {
            printf("Saved giftbox id %d", giftboxid);
        }
        else
        {
            printf("An error has occured while saving the giftbox");
        }
        return 1;
    }
But I'm sure you've done the giftbox defines wrong, this one looks weird
pawn Код:
if(IsPlayerInRangeOfPoint(playerid, 5.0, GiftBoxInfo[playerid][pGiftBoxPosX], GiftBoxInfo[playerid][pGiftBoxPosY], GiftBoxInfo[playerid][pGiftBoxPosZ]))
pawn Код:
for(new i = 0; i < MAX_PLAYERS; i++) //you could've done a MAX_GIFTBOX
{
    if(IsPlayerInRangeOfPoint(playerid, 5.0, GiftBoxInfo[i][pGiftBoxPosX], GiftBoxInfo[i][pGiftBoxPosY], GiftBoxInfo[i][pGiftBoxPosZ]))
    {
        //rest of your code
    }
}
Please search before posting and read this https://sampwiki.blast.hk/wiki/MySQL/R33 and this https://www.guru99.com/delete-and-update.html
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)