Many thanks Thomas and Maciek. I'll try removing mt_srand to start with,
and if that doesn't work out I'll put in the uniqueness check.
Cheers,
Gordon.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Use a database query to verify the random number has not been used before.
$number_checker = 1;
while ($number_checker != 0){
#insert your $random_number code
$query = "SELECT COUNT(*) AS total FROM some_table WHERE
random_number_field = '$random_number'";
$result = mysq
Gordon McKeown wrote:
Apologies, my mail client was supposed to line-wrap that for me
-
Hi,
I'm currently experiencing a problem with a phpBB board that appears
to be due to the way random number generation works in PHP. I have
posted on serveral phpBB boards and have received no answers, s
Apologies, my mail client was supposed to line-wrap that for me
-
Hi,
I'm currently experiencing a problem with a phpBB board that appears
to be due to the way random number generation works in PHP. I have
posted on serveral phpBB boards and have received no answers, so I
think I need to un
3B733@BOOTROS...
> The manual also says:
> mt_rand -- Generate a better random value
>
> I've been using mt_rand() over rand() every time - is there any reason not
> to?
>
> Cheers
> Jon
>
>
> -Original Message-
> From: elias [mailto:[EMAIL PROTECTED
The manual also says:
mt_rand -- Generate a better random value
I've been using mt_rand() over rand() every time - is there any reason not
to?
Cheers
Jon
-Original Message-
From: elias [mailto:[EMAIL PROTECTED]]
Sent: 03 May 2001 00:05
To: [EMAIL PROTECTED]
Subject: Re: [PHP] R
Regards,
Avetis
[EMAIL PROTECTED] wrote:
> Hi there,
> A potentially dumb question here.
>
> Is there an easy way to display a random number between 1 and 20?
>
> I have looked on line, but either I am looking inall teh wrong places, or there
> isn't this script on-line.
>
> Can anyone point m
Wotcha Tris :-)
Try this:
mt_srand((double)microtime()*100);
$my_random_number = mt_rand(1, 20);
HTH
Jon
-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]
Sent: 02 May 2001 12:07
To: [EMAIL PROTECTED]
Subject: [PHP] Random number generation...
Hi there,
A p
why not use the rand() ?
manual says:
rand -- Generate a random value
Description
int rand ([int min [, int max]])
If called without the optional min, max arguments rand() returns a
pseudo-random value between 0 and RAND_MAX. If you want a random number
between 5 and 15 (inclusive), for examp
9 matches
Mail list logo