Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Random user ID generating...
Old 06-11-2005, 09:24 PM Random user ID generating...
ccp
ccp's Avatar
Average Talker

Posts: 28
Trades: 0
Hypothetical question...

If I use the rand() function to generate user_ids what are the chances that I will get a duplicate ID for someone who is registering for the first time?

If it is likely that the rand() function will spit out the same number more than once is it wise to do a check to see if the ID is already in the db? maybe a dumb q.

Also, is it possible to generate a number or ID in a certain format suck as "3498-484DjL"?
I think that would be better than regular numbers....

thanks for any insight on this.
later.
ccp is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 06-12-2005, 07:00 AM
Unknown.

Posts: 1,693
Trades: 0
Why the need for the complicated IDs?

Why not just have the field as a number then set the field to auto increment then everytime you enter a record into that table in the database the id field will increase by one.. thats the general way everyone does it..
Dark-Skys99 is offline
Reply With Quote
View Public Profile
 
Old 06-13-2005, 02:16 AM
mtishetsky's Avatar
King Spam Talker

Posts: 1,226
Name: Mike
Location: Mataro, Spain
Trades: 0
Also time() will never return the same value (unless two users wil register at the same moment).
__________________

Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE

And don't forget to give me talkupation!
mtishetsky is offline
Reply With Quote
View Public Profile Visit mtishetsky's homepage!
 
Old 06-13-2005, 03:00 AM
ccp
ccp's Avatar
Average Talker

Posts: 28
Trades: 0
yeah ok so how do you handle a user that is no longer active? Do you delete the user altogether or do you change a field in the table saying he is no longer active? If I delete him his user ID goes with him right? Then I will have a table with users with IDs that don't follow sequentially. I just don't know if that is going to pose a problem in the future...

I was doing it the auto increment way until I noticed that when I delete a ficticious user (still in production stages) and then test the register script again I see that the auto number skips whatever ID number was deleted. Since this is my first real web app I don't want any issues with the DB.

just worried in BK,NY.
ccp is offline
Reply With Quote
View Public Profile
 
Old 06-13-2005, 10:48 AM
Chris_krasnichu's Avatar
Ultra Talker

Posts: 331
Location: Ontario, Canada
Trades: 0
well you can have the script check the db to see if the ID is already in use, if it is you can just loop the script untill the ID isn't in use.

Chris
__________________
Name: Chris Krasnichuk
Email Address:
Please login or register to view this content. Registration is FREE
Chris_krasnichu is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Random user ID generating...
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.24612 seconds with 12 queries