RE: [PHP] problems with mt_rand()

2002-01-31 Thread Matthew Walker

Did you remember to seed it? 

See http://www.php.net/manual/en/function.mt-srand.php for info on how
to seed it.

Matthew Walker
Ecommerce Project Manager
Mountain Top Herbs


-Original Message-
From: Benjamin deRuyter [mailto:[EMAIL PROTECTED]] 
Sent: Thursday, January 31, 2002 1:02 PM
To: PHP
Subject: [PHP] problems with mt_rand()

I need to generate a random number (range is not crucial) and I have
been
trying to use mt_rand().  However, I am finding that is generates the
same
value EVERY time.  This is true whether I supple a range or not.  For
example, the follow line of code generated 13 EVERY time...

$result = mt_rand(1,15);
echo $result;

In addition, this line of code generated 1755202938 EVERY time...

$result = mt_rand();
echo $result;

What am I doing wrong??

 - Ben


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]



---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.317 / Virus Database: 176 - Release Date: 1/21/2002
 

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.317 / Virus Database: 176 - Release Date: 1/21/2002
 

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] problems with mt_rand()

2002-01-31 Thread Christopher William Wesley

On Thu, 31 Jan 2002, Benjamin deRuyter wrote:

> I need to generate a random number (range is not crucial) and I have been
> trying to use mt_rand().  However, I am finding that is generates the same
> value EVERY time.  This is true whether I supple a range or not.  For
> example, the follow line of code generated 13 EVERY time...

27-Mar-2001 07:29

Don't forget to do mt_srand() before the mtrand() or you wil get the same
values every time you'll go back to the same page.Not when you refresh
the page, only when you open the page in a new browserwindow and the
history is empty.

http://www.php.net/manual/en/function.mt-rand.php

~Chris   /"\
 \ / September 11, 2001
  X  We Are All New Yorkers
 / \ rm -rf /bin/laden


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]