Re: Random
| From: | Knut H. Hassel Nielsen | Date: | Wed, 19 Dec 2001 17:38:30 +0000 |
| Subject: | Re: Random | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-78227@lists.php.net to get a copy of this message | ||
On Thu, 20 Dec 2001, Necro wrote:
> Lo all,
>
> Can anyone please explain why this doesn't work...
>
> $floor = 100000;
> $ceiling = 999999;
> srand((double)microtime()*1000000);
> $random = rand($floor, $ceiling);
>
> I get the error...
> Warning: rand(): Invalid range: 100000..999999 in
> d:\htdocs\ezone\web\signup2.php on line 49
>
> Thankyou
>
> Andrew
Hi there.
I see you use windows, but when I looked up 'microtime' in
the manual it says the following :
-------
microtime
microtime -- Return current UNIX timestamp with microseconds
Description
string microtime(void);
Returns the string "msec sec" where sec is the current time measured in the
number of seconds since the Unix Epoch (0:00:00 January 1, 1970 GMT), and
msec is the microseconds part. This function is only available on operating
systems that support the gettimeofday() system call.
See also time().
-------
So you'll probably have to use something else for your rand (or change OS ;) )
Good luck, and a merry Christmas to you.
--
Knut
------
Knut H. Hassel Nielsen, knutnie@idi.ntnu.no
Principal Engineer, Office : ITS 204
IDI NTNU, Sem Saelands vei 7-9
N-7491 Trondheim, Norway
Phone (+47) 73 59 18 46 Fax (+47) 73 59 60 35
"Programmers don't die, they just GOSUB without RETURN."