Hey folks, I'm creating a database that has existing customer information in it. All I did was dump the ODBC database, convert it to MySQL and then import it into the MySQL database. I've now played around with it so that there are 4 columns: id, user_name, pass_word and cust_name. Every column is populated except for the password column. I grabbed a random password generator script off of hotscripts, and I've tried to modify it so that it will input a random password for each customer all in one fell swoop. Here's the code:
<?php
include "config.php";
function random_char($string)
{
$length = strlen($string);
$position = mt_rand(0, $length - 1);
return($string[$position]);
}
function random_string ($charset_string, $length)
{
$return_string = random_char($charset_string);
for ($x = 1; $x < $length; $x++)
$return_string .= random_char($charset_string);
return($return_string);
}
mt_srand((double)microtime() * 1000000);
$charset = "abcdefghijklmnopqrstuvwxyz12_34567890ABCDE_FGHIJKLMNOPQRSTWXYZ";
$dbcx = mysql_connect($dbhost,$dbuser,$dbpass);
mysql_select_db("CUSERS",$dbcx);
$sql1 = "UPDATE cusers SET pass_word = '".$password."' WHERE id = '".$count."'";
$count = 1;
while($count <= 1474)
{
$password = random_string($charset, 8);
mysql_query($sql1,$dbcx);
$count++;
}
?>
There are 1474 existing records in the database...I just don't understand why this isn't working. After I run it, the pass_word column's are all still blank.
Any help is appreciated.