Okay the the script is attached below.  i am baffled at the problem.  as you
can see the script does a rather simplistic generation of passwords.  it
then writes them into two files.

the problem is the first time i run (i am running it stand alone)  it works
fine and the result is two files with 32 entries (and the mysql entries are
also correct).  the second time i run it.  i (there should be 44 new entries
make one file with 76 entries and another with 44)

however what i get is a file with 1233 entries and another with 1201.

now i admit the code is not beautiful but my concern is more of what is
causing this.  i have checked the variables both $i and $rows appear fine.

when i look at the text files what i see is it assigns the 44 entries and
then repeats them.  all i can figure is it is the conditional or whiel loop?
why does it work perfect the first time??


<?php
mysql_connect("localhost:/var/run/mysql/mysql.sock");
mysql_select_db("VQRGDATA");
$letter = array("Gob", "Lol", "woZ", "Kop", "MoS", "tRu", "SAw", "NoR",
"TEf","TaF", "JoP", "lOg", "tAn", "FiSH", "cAT", "VAn", "bAb", "Mob",
"KorN", "BeAt", "roSe", "KlaP", "iZ", "GEr", "HaT", "ZaaM", "toAd", "emU");
$results = mysql_query("SELECT members.id, members.lname FROM members, users
WHERE users.id <> members.id");
$rows= mysql_num_rows($results);
if($rows != 0)
{
while($info = mysql_fetch_array($results))
{
if($info[0] != 0)
{
$ids[] = $info[0];
$lnames[] = $info[1];
}
}
mysql_free_result($results);
$i=0;
while($i < $rows-1)
{
srand((double) microtime() * 1000000);
$pass_letter_key = array_rand($letter);
srand((double) microtime() * 1000000);
$pass_num1 = mt_rand(0, 26);
srand((double) microtime() * 1000000);
$pass_num2 = mt_rand(100, 926);
$strip = trim($lnames[$i]);
$lower = strtolower($strip);
$infochop = substr($lower, -5, 4);
$username = $infochop.$pass_num2;
$password = $pass_num1. $letter[$pass_letter_key].$pass_num2;
$respass = mysql_query("SELECT password FROM users WHERE
password='$password'");
$pass_row = mysql_num_rows($respass);
if(!$pass_row)
{
mysql_query("INSERT INTO users(id, username,password) VALUES('$ids[$i]',
'$username', '$password') ");
$complete = fopen("complete.txt", "a+");
$input[] = $ids[$i]."\t".$username."\t".$password."\n";
fputs($complete, $input[$i]);
fclose($complete);
$i++;
}
mysql_free_result($respass);

}
}
$new = implode("", $input);
$newtxt = fopen("new.txt", "w");
fputs($newtxt, $new);
fclose($newtxt);
?>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to