note 18612 rejected from function.mt-rand by rioter

From: Date: Tue, 25 Feb 2003 07:55:34 +0000
Subject: note 18612 rejected from function.mt-rand by rioter
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-44480@lists.php.net to get a copy of this message
well, the rand function works, but looks like it has a limitation to it. look at this : function calcres($number) { global $Supplies; srand ((double) microtime() * 1000000); $retval = 0; $a = 0; if ($a!=$number) { do { $a++; $tmp = rand(0,3+($roids+$retval)); if ($tmp<20) $retval++; }while($a<$number); } return $retval; } Later it takes this random number and adds it to the data base fine. adding to the random numbers up until you hit a specific point. now, while this works fine, when you hit "32780" or around there in the data base(in this case mySQL) you then get errors showing that the line is out of range. like the following: Warning: rand(): Invalid range: 0..32780 in ..usr\inet\waves.php on line 20 What can be done to overcome this possible limitation? My question is, would there be a workaround or fix to this limitation? or is this a limitation of the rand() function? and not a bug in this programming structure.

« previous php.notes (#44480) next »