Register Members List Search Today's Posts Mark Forums Read

Reply
 
Thread Tools
  #1  
Old 09 Feb 2006, 19:45
Red Blaze's Avatar
Red Blaze Red Blaze is offline
 
Join Date: Jan 2003
Real name: Frank E.
Random Number, if duplicate?


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

I want to use this random code generator, to store in the database a code. I want this number to be unique. How can I keep PHP from duplicating a code saved in the database?

I can tell MySQL to keep it unique, but I don't want an error page. I want to keep errors to a minimum. Thank you for the help.

I was thinking of a loop to check if it exists until it finds a unique number and end the loop before it spits out the page with the code in a hidden field. I just don't know what codes to use. >_<
Reply With Quote
  #2  
Old 09 Feb 2006, 19:51
Marco van Herwaarden Marco van Herwaarden is offline
 
Join Date: Jul 2004
What are you trying to do with this?
__________________
Marco van Herwaarden
Ex vBulletin.org Coordinator
Reply With Quote
  #3  
Old 09 Feb 2006, 19:55
Red Blaze's Avatar
Red Blaze Red Blaze is offline
 
Join Date: Jan 2003
Real name: Frank E.
Well, I want this for a gallery. When someone makes an album, the random number generator would create a number. The user would have to keep this to go back to view the album. Kind of like a passcode... key kinda thing.
Reply With Quote
  #4  
Old 09 Feb 2006, 20:00
Danny.VBT's Avatar
Danny.VBT Danny.VBT is offline
 
Join Date: Oct 2004
Why not just use mysql's auto_increment attribute, which adds a unique identifer to table rows?
__________________
while($coffeeMachine->supply($Danny)) { $Danny->run(); }

Twitter Blog
Reply With Quote
  #5  
Old 09 Feb 2006, 20:03
Red Blaze's Avatar
Red Blaze Red Blaze is offline
 
Join Date: Jan 2003
Real name: Frank E.
Well, I don't want single digit keys. Otherwise, random people will just type 1, 2, 3, 4, 5...and have access where they're not suppose to be.
Reply With Quote
  #6  
Old 09 Feb 2006, 20:07
Marco van Herwaarden Marco van Herwaarden is offline
 
Join Date: Jul 2004
So you want to make it that anybody that want to view an album needs a password? Or just the original owner of the album when they want to edit it?
__________________
Marco van Herwaarden
Ex vBulletin.org Coordinator
Reply With Quote
  #7  
Old 09 Feb 2006, 20:10
Red Blaze's Avatar
Red Blaze Red Blaze is offline
 
Join Date: Jan 2003
Real name: Frank E.
If the users types in the correct passcode, they can view the album.
Reply With Quote
  #8  
Old 09 Feb 2006, 20:16
Marco van Herwaarden Marco van Herwaarden is offline
 
Join Date: Jul 2004
And how will they get that password?

Wouldn't it be easiest if you let the user who creates the album just let choose a password?
__________________
Marco van Herwaarden
Ex vBulletin.org Coordinator
Reply With Quote
  #9  
Old 09 Feb 2006, 20:19
Red Blaze's Avatar
Red Blaze Red Blaze is offline
 
Join Date: Jan 2003
Real name: Frank E.
It would be emailed to them.
lol I have it figured out. I just want to know how to keep it from duplicating; if it ever happend.
Reply With Quote
  #10  
Old 09 Feb 2006, 20:21
Paul M's Avatar
Paul M Paul M is offline
 
Join Date: Sep 2004
Real name: Paul Marsden
Why does it matter if you happen to get a duplicate ?
__________________


Lead Developer, vBulletin.Org & vBulletin.Com
Please do not PM me about custom work - I no longer undertake any.

Note: I will not answer support questions via e-mail or PM - please use the relevant thread or forum.
Cable Forum - DigiGuide
Reply With Quote
  #11  
Old 09 Feb 2006, 20:26
Red Blaze's Avatar
Red Blaze Red Blaze is offline
 
Join Date: Jan 2003
Real name: Frank E.
I wouldn't want to run into a problem if two albums have the same key.
Reply With Quote
  #12  
Old 09 Feb 2006, 20:28
Paul M's Avatar
Paul M Paul M is offline
 
Join Date: Sep 2004
Real name: Paul Marsden
What problem exactly ?
__________________


Lead Developer, vBulletin.Org & vBulletin.Com
Please do not PM me about custom work - I no longer undertake any.

Note: I will not answer support questions via e-mail or PM - please use the relevant thread or forum.
Cable Forum - DigiGuide
Reply With Quote
  #13  
Old 09 Feb 2006, 20:30
Red Blaze's Avatar
Red Blaze Red Blaze is offline
 
Join Date: Jan 2003
Real name: Frank E.
What I want is to filter the albums by a key. I just want one album per key. If two albums is to have the same key, both albums would be displayed. I do not want that. I want them to be displayed individually.
Reply With Quote
  #14  
Old 09 Feb 2006, 20:31
Paul M's Avatar
Paul M Paul M is offline
 
Join Date: Sep 2004
Real name: Paul Marsden
Prefix it with the userid then.
__________________


Lead Developer, vBulletin.Org & vBulletin.Com
Please do not PM me about custom work - I no longer undertake any.

Note: I will not answer support questions via e-mail or PM - please use the relevant thread or forum.
Cable Forum - DigiGuide
Reply With Quote
  #15  
Old 09 Feb 2006, 20:33
Marco van Herwaarden Marco van Herwaarden is offline
 
Join Date: Jul 2004
Use an autoincrement albumid as identification, the random key as password.
__________________
Marco van Herwaarden
Ex vBulletin.org Coordinator
Reply With Quote
Reply


Similar Threads
Thread Thread Starter Forum Replies Last Post
Random Number BBCode spongebobrox128 vBulletin 3.5 Add-ons 13 02 Apr 2006 20:58

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Thread Tools

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


New To Site? Need Help?

All times are GMT. The time now is 06:54.

Layout Options | Width: Wide Color: