Welcome Guest, Not a member yet? Register   Sign In
Generating Unique ID
#1

[eluser]Kemik[/eluser]
Hello,

I'm trying to generate a unique ID for a personal file upload script. I was looking for a 5 character string consisting of alphanumeric characters, both upper and lower.

Is there any way of making it truly unique? E.g. based off the current time or would that be too much hassle? If it isn't possible I was just going to use the below script and do a check in the database to make sure it hasn't already been used.

Code:
function createRandomPassword() {

    $chars = "abcdefghijkmnopqrstuvwxyz023456789";
    srand((double)microtime()*1000000);
    $i = 0;
    $pass = '' ;

    while ($i <= 5) {

        $num = rand() % 33;
        $tmp = substr($chars, $num, 1);
        $pass = $pass . $tmp;
        $i++;

    }
    return $pass;
}


Messages In This Thread
Generating Unique ID - by El Forum - 07-06-2008, 11:14 AM
Generating Unique ID - by El Forum - 07-06-2008, 11:23 AM
Generating Unique ID - by El Forum - 07-06-2008, 12:59 PM
Generating Unique ID - by El Forum - 07-06-2008, 04:11 PM
Generating Unique ID - by El Forum - 07-06-2008, 04:19 PM
Generating Unique ID - by El Forum - 07-06-2008, 04:30 PM
Generating Unique ID - by El Forum - 07-06-2008, 06:07 PM
Generating Unique ID - by El Forum - 07-06-2008, 06:23 PM
Generating Unique ID - by El Forum - 07-06-2008, 07:32 PM
Generating Unique ID - by El Forum - 07-06-2008, 08:41 PM
Generating Unique ID - by El Forum - 07-06-2008, 10:18 PM
Generating Unique ID - by El Forum - 07-06-2008, 10:35 PM
Generating Unique ID - by El Forum - 07-06-2008, 11:48 PM
Generating Unique ID - by El Forum - 07-07-2008, 12:27 AM
Generating Unique ID - by El Forum - 07-07-2008, 12:53 AM
Generating Unique ID - by El Forum - 07-07-2008, 01:07 AM



Theme © iAndrew 2016 - Forum software by © MyBB