why doesnt update in database -
enzulikeS - 06.01.2019
Код:
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..
Re: why doesnt update in database -
enzulikeS - 07.01.2019
Quote:
Originally Posted by ******
There's no `WHERE`.
|
i don t get it what to do :<
Re: why doesnt update in database -
Eoussama - 07.01.2019
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.
Re: why doesnt update in database -
enzulikeS - 08.01.2019
added WHERE `ID` but still nope..
Re: why doesnt update in database -
enzulikeS - 09.01.2019
Код:
mysql_format(SQL,zzString,sizeof(zzString),"UPDATE `giftboxd` SET `GiftBoxMoney`='%s' WHERE `GiftBoxOn`='1'", GiftBoxInfo[playerid][pGiftBoxMoney], GiftBoxInfo[playerid][pGiftBoxOn]);
mysql_tquery(SQL,zzString,"","");
Re: why doesnt update in database -
enzulikeS - 11.01.2019
anyone please?
Re: why doesnt update in database -
userid - 11.01.2019
Maybe you should start learning sql
Re: why doesnt update in database -
d3Pedro - 11.01.2019
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