3
Here is the script I wrote to do what I needed, you could modify it very easily to copy out any information you wanted.
//MySQL Main DB Connection & Selection
$conn_main=mysql_connect("dbhost1", "dbusername", "dbpassword");
mysql_select_db("dbname",$conn_main);
//MySQL Gallery DB Connection & Selection
$conn_gallery=mysql_connect("dbhost2", "dbusername", "dbpassword");
mysql_select_db("dbname",$conn_gallery);
//Delete from Gallery DB
$delete_sql="delete from gallery_users";
mysql_query ($delete_sql,$conn_gallery) or die (mysql_error());
//Select data from Main DB (Outer Loop)
$totalsql="select uid from xoops_users order by uid desc limit 1";
$totalquery=mysql_query($totalsql,$conn_main);
while ($totalrow = mysql_fetch_array ($totalquery)) {
$totalcount=$totalrow['uid'];
}
$loopcount1=1;
while ($loopcount1 <= $totalcount) {
$xoops_sql="select uid,uname,pass from xoops_users where uid=$loopcount1";
$select_sql=mysql_query($xoops_sql,$conn_main) or die (mysql_error());
while ($row1 = mysql_fetch_array ($select_sql)) {
$phpuname=$row1['uname'];
$phppass=$row1['pass'];
}
if(isset($phpuname)) {
$gallery_sql="insert into gallery_users values ('$phpuname','$phppass')";
$insert_sql=mysql_query($gallery_sql,$conn_gallery) or die (mysql_error());
$loopcount1=$loopcount1+1;
unset($phpuname);
unset($phppass);
}
else {
$loopcount1=$loopcount1+1;
}
}
//Close MySQL Connections
mysql_close($conn_main);
mysql_close($conn_gallery);
?>
Jonathan