Hey,
I have a table with names and i want to create usernames and passwords for every name. So I have to update the whole database, but the way I try it only returns the "Supplied argument is not a valid MySQL..." error when I run at the WHILE-Statement.
<?php
$db = mysql_connect("localhost", "root", "password");
mysql_select_db("abi",$db);
$result = mysql_query("SELECT * FROM identity",$db);
$username=0;
while ($myrow = mysql_fetch_array($result))
{
$username++;
$current_id=$myrow["id"];
srand((double)microtime()*1000000);
$ix=rand(1,9);
$sql = "UPDATE identity SET user_name='$username',user_password='$ix' WHERE id=$current_id";
$result = mysql_query($sql);
}
?>
Please help me...
thanx phlow
I have a table with names and i want to create usernames and passwords for every name. So I have to update the whole database, but the way I try it only returns the "Supplied argument is not a valid MySQL..." error when I run at the WHILE-Statement.
<?php
$db = mysql_connect("localhost", "root", "password");
mysql_select_db("abi",$db);
$result = mysql_query("SELECT * FROM identity",$db);
$username=0;
while ($myrow = mysql_fetch_array($result))
{
$username++;
$current_id=$myrow["id"];
srand((double)microtime()*1000000);
$ix=rand(1,9);
$sql = "UPDATE identity SET user_name='$username',user_password='$ix' WHERE id=$current_id";
$result = mysql_query($sql);
}
?>
Please help me...
thanx phlow