"These values ARE being stored
in a database; however, once this database gets to a million or so rows, it
would take a very long time to check it doesn't overlap, wont it?"

Well, you **could** make a database of ALL possibilities and delete each
possibility as it is used  :)  Then the program would run faster and faster
and you could tell people you've been tweaking the code while it's actually
running faster all on its own  :)

---------------------
John Asendorf - [EMAIL PROTECTED]
Web Applications Developer
http://www.lcounty.com - NEW FEATURES ADDED DAILY!
Licking County, Ohio, USA
740-349-3631

The benefit to the government of replacing all $1 Federal Reserve notes with
$1 coins would be $522.2 million per year, according to estimates of the
General Accouting Office released on April 7, 2000.


> -----Original Message-----
> From: phobo [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, January 23, 2001 3:48 PM
> To: [EMAIL PROTECTED]
> Subject: Re: [PHP-WIN] Random Code
> 
> 
> Oops, 36^8 :)
> 
> This value would only have to generated perhaps a few times 
> an hour, but
> should't take more than a second to compute. These values ARE 
> being stored
> in a database; however, once this database gets to a million 
> or so rows, it
> would take a very long time to check it doesn't overlap, wont it?
> 
> I also thought about getting the current date/time stamp and 
> representing it
> as this value. This code is an online-order reference number, 
> so it could be
> something like seconds since midnight:
> 
> 36^4 = 1,679,616
> Seconds in a day (60.60.24) = 86400
> 
> A really effective way would be to get a subsecond count for 
> the day; so
> that 0000 is midnight, and ZZZZ is the end of the that day. 
> This means there
> are about 19 increments a second, which rules out any possibility of
> duplicates, because:
> 
> 1. two other characters could be the id of the user (a 
> numeric value). 36.36
> is 33696, which is much higher than the intended number of 
> users on the
> system (we invisage no more than a few hundred - by the time 
> the userbase
> gets to 33000, I'll be a millionairre and this can be someone 
> else's job
> hehe)
> 
> 2. the two remaining characters could be a day/year thing. 
> perhaps the days
> since the start of the year 2000. 33696/365 is 92; this 
> system will not be
> used for 92 years!
> 
> Does that sound like quite a good algorythm, or do you have a 
> much easier,
> simpler way?
> 
> Siggy
> 
> 
> 
> ----- Original Message -----
> From: "Larry Forrister" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Wednesday, January 24, 2001 7:26 AM
> Subject: Re: [PHP-WIN] Random Code
> 
> 
> > Do you mean  W3E4-22ER  would be valid?  If so there would be 36^8
> > (2,821,109,907,456) possible values.
> >
> > A truly random generator algorithm cannot guarantee uniqueness.  I'm
> > guessing what you want is to generate each possible value once in a
> > pseudo-random order.  Would just apparent randomness suffice?
> >
> > With what frequency do the values need to be generated?  
> Once every few
> > seconds/minutes or multiple times per second?
> > ~~LF
> >
> >
> > Sigurd Magnusson wrote:
> >
> > > Whats the best way to make a completely random, unique code in the
> > > format "ABCD-1234" where each of the 8 characters can be 
> alphanumerc;
> > > 0-9,A-Z... I thought about generating a 36^4 number, 
> converting to to
> > > base '36', and repeating the process. What's a good way 
> to ensure the
> > > code is not repeated, though?
> > >
> > > Siggy
> >
> > --
> > PHP Windows 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]
> >
> >
> 
> 
> -- 
> PHP Windows 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]
> 

-- 
PHP Windows 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]

Reply via email to