PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
tapas_bahirbag
Forum Newbie
Posts: 14 Joined: Sun Aug 06, 2006 6:54 am
Contact:
Post
by tapas_bahirbag » Sun Jul 01, 2007 3:05 am
how can i generate random alphanumeric code of length 5 and must be unique every time?
please help me.
Thanks,
Tapos Pal
Benjamin
Site Administrator
Posts: 6935 Joined: Sun May 19, 2002 10:24 pm
Post
by Benjamin » Sun Jul 01, 2007 3:11 am
You can generate a random alpha numeric string and store it in a database once it has been used.
tapas_bahirbag
Forum Newbie
Posts: 14 Joined: Sun Aug 06, 2006 6:54 am
Contact:
Post
by tapas_bahirbag » Sun Jul 01, 2007 3:15 am
but, i dont want to check database for uniqueness.
miro_igov
Forum Contributor
Posts: 485 Joined: Fri Mar 31, 2006 5:06 am
Location: Bulgaria
Post
by miro_igov » Sun Jul 01, 2007 3:34 am
Then save all used codes in a file and read it each time before to issue new code
No other way for uniqueness.
califdon
Jack of Zircons
Posts: 4484 Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA
Post
by califdon » Sun Jul 01, 2007 5:15 am
And please use a descriptive Subject for any future posts. Subjects like "Help!" are usually ignored by most of us.
superdezign
DevNet Master
Posts: 4135 Joined: Sat Jan 20, 2007 11:06 pm
Post
by superdezign » Sun Jul 01, 2007 6:08 am
tapas_bahirbag wrote: but, i dont want to check database for uniqueness.
So what? If you want it to be unique as according the database, you have to use the database for it.
tapas_bahirbag
Forum Newbie
Posts: 14 Joined: Sun Aug 06, 2006 6:54 am
Contact:
Post
by tapas_bahirbag » Sun Jul 01, 2007 7:32 am
thanks for reply. my code is now running. i use database for uniqueness.
Regards,
Tapos Pal