<?
$host = "hostname";
$user = "usernamedb";
$pass = "passworddb";
$base = "nomdeladb";
$mysql_link = mysql_pconnect($host, $user, $pass);
mysql_select_db($base) or die( "Connexion impossible à la base de donnée !!! " );
function gen_password($taille_pwd)
{
$tab_char="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
while($i<$taille_pwd)
{
$nombre_aleatoire .= $tab_char[rand(0,strlen($tab_char))];
$i++;
}
return $nombre_aleatoire;
}
$req="SELECT * FROM ta_table";
$res=mysql_query($req);
srand(microtime());
while($result=mysql_fetch_array($res))
{
$gen_pwd=gen_password(10);
$cleprim=$result["ClePrimaireDeTaTable"];
mysql_query("UPDATE ta_table SET champ_password='$gen_pwd' WHERE ClePrimaireDeTaTable='$cleprim'" );
}
?> |