SA-MP Forums Archive
MySQL Query loads data incorrectly - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: MySQL Query loads data incorrectly (/showthread.php?tid=585138)



MySQL Query loads data incorrectly - ZBits - 11.08.2015

Hello!,

So i am trying to retrieve data from my MySQL table and it seems to be retrieving data twice.

pawn Код:
for(new i, k = cache_get_row_count(Connection); i < k; i++)
 {
        Weapon_ID   = cache_get_row_int(i, 0, Connection);
        Ammo        = cache_get_row_int(i, 1, Connection);
        printf("Ammo: %d",Ammo);
}
There is only 1 row of data and the Ammo amount is 100. However upon login it gives 200. It keepts doubling the ammo value. I tried debugging and this was the result.

Код:
Ammo: 100
Ammo: 100
Help would be appreciated!


Re: MySQL Query loads data incorrectly - ZBits - 12.08.2015

I'd like to give this a bump.


Re: MySQL Query loads data incorrectly - SickAttack - 12.08.2015

Did you try the below?
pawn Код:
i <= k



Re: MySQL Query loads data incorrectly - ZBits - 12.08.2015

Quote:
Originally Posted by SickAttack
Посмотреть сообщение
Did you try the below?
pawn Код:
i <= k
I did try that, gave the same result.

Debug Log:

Код:
 
[20:30:57] Ammo: 100
[20:30:57] Ammo: 0
[20:30:57] Ammo: 100
[20:30:57] Ammo: 0
EDIT: its also loading the weapon the same way

Код:
Weapon_ID: 24 | Ammo: 100
Weapon_ID: 0 | Ammo: 0
Weapon_ID: 24 | Ammo: 100
Weapon_ID: 0 | Ammo: 0



Re: MySQL Query loads data incorrectly - SickAttack - 12.08.2015

How many rows does it return and how many rows do you have?


Re: MySQL Query loads data incorrectly - ZBits - 12.08.2015

I got 1 row. And it seems to be returning 4 rows with
Код:
<=
and 2 rows with
Код:
<



Re: MySQL Query loads data incorrectly - SickAttack - 12.08.2015

But what does "cache_get_row_count(Connection)" possess?

Anyway, if you get two, then "for(new i = 1;...".


Re: MySQL Query loads data incorrectly - ZBits - 12.08.2015

cache_get_row_count prints out

Код:
Account Name: Zbits
that is really werid.


Re: MySQL Query loads data incorrectly - SickAttack - 12.08.2015

Nice, let's validate the name as a value.


Re: MySQL Query loads data incorrectly - ZBits - 12.08.2015

Quote:
Originally Posted by SickAttack
Посмотреть сообщение
Nice, let's validate the name as a value.
what?