I don't see why your code is so wrong .... but neither do I see what it
reall does. YOu are changing the clientID with some simple function into a
password? As in everybody can do that trick by himself and login as whoever
he wants ..

What I'll mostly do for such things, is use this self written function to
generate a random string and use this as generated password. it takes an
integer as argument, and gives back a random code with only [A-Z][a-z]
characters of a length of the given argument.

And then, I'd just use the loop to roll through the ID's and insert a random
code password.

function generateRandomString($length) {
        srand ((float) microtime() * 1000000);
        for ($i=65;$i<91;$i++) {
                $chars[] = chr($i);
        for ($i=97;$i<122;$i++) {
                $chars[] = chr($i);
        $chrs = count($chars) - 1;
        for ($i=0; $i<$length; $i++) {
                $asc = rand(0, $chrs);
                $code .= $chars[$asc];
        return $code;

$result = mysql_query("SELECT clientid FROM Clientdetails");
while ($myrow = mysql_fetch_assoc($result)) {
        $code = generateRandomString(8);
        mysql_query("INSERT INTO authentication (id, pass) VALUES
($myrow[clientid], '".$code."'");

Hope this helped you !


-----Oorspronkelijk bericht-----
Van: Thomas Edison Jr. [mailto:[EMAIL PROTECTED]]
Verzonden: woensdag 24 juli 2002 9:02
Onderwerp: [PHP] Inserting Processed Data from One Table 2 Another!

Ok i have simple issue, i'm stuck at one point.

I have a table "Clientdetails" which contains
I have created another table "Authentication" with 2
fields, "ClientID" and "Password".

I want to pick up the ClientID from table
"Clientdetails" and insert "ClientID" and a Password i
have generated using a code, into "Authentication".

So if there are 13000 ClientID's in "Clientdetails",
as, many rows with the ClientID & it's corresponding
password should be Inserted into table

I'm using the following code which i know is wrong,
what would be correct?

$db = mysql_connect("localhost","user","pwd");

$result = mysql_query("SELECT * FROM
if ($myrow = mysql_fetch_array($result)) {
do {

$some = $myrow[clientid]
$newid = eregi_replace('100', '', $myrow[clientid]);
$date = date("dn");
$stuff = $newid.def.$date;

$sql = "INSERT INTO authentication
$result = mysql_query($sql);
echo "All Done!";

} while ($myrow = mysql_fetch_array($result));


T. Edison Jr.

Do You Yahoo!?
Yahoo! Health - Feel better, live better

PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to