getting the max int from a mysql column - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: getting the max int from a mysql column (
/showthread.php?tid=203831)
getting the max int from a mysql column -
The_Gangstas - 28.12.2010
pawn Код:
GetTempBanSlot()
{
mysql_query("SELECT MAX(Banid) FROM Bans");
mysql_store_result();
new slot = mysql_fetch_int();
mysql_free_result();
if(slot <= 0) slot = 0;
return slot+1;
}
it always returns 1.
Re: getting the max int from a mysql column -
willsuckformoney - 28.12.2010
pawn Код:
if(slot <= 0) return slot = 0;
Slot being 0 before +1 = 1.
Re: getting the max int from a mysql column -
The_Gangstas - 28.12.2010
what are u talking about? i put that there if its -0 but theres 1 in table.. should it should return 2?
Re: getting the max int from a mysql column -
Austin - 28.12.2010
All uppercase/lowercase is correct?
Re: getting the max int from a mysql column -
willsuckformoney - 28.12.2010
Your confusing me... You have:
pawn Код:
if(slot <= 0) slot = 0;
return slot+1;
Meaning equals 0 or less than 0 then set to one.
So I suggest that:
pawn Код:
mysql_query("SELECT MAX(Banid) FROM Bans");
That is already 0 or less.
and return slot+1 will set to 1. Setting something to 0 and adding 1 trying to get higher than 1 will not work.
Re: getting the max int from a mysql column -
Calgon - 28.12.2010
1 is the default auto incrementing number, do you have any more rows?