Not sure what you are exactly tyring to do, if you want to copy or backup a database, MOST database engins have utilitys to do this kind of thing. But you can read data from one database in PHP and put in it another like this
$database_connection = mysql_connect("server", "username", "password");
mysql_select_db("db_name",$database_connection);
$sql = "select from db1";
$rs = mysql_query($sql, $database_connection);
// change databases
mysql_select_db("db_name2", $database_connection);
while ($results = mysql_fetch_object($rs)) {
$sql = "insert into db2";
mysql_query($sql);
}
now this assumes that both databases are on the same server and the one username has access to both... If either of these are not the case then you will have to make a second database connection...
Hope this helps..
PHPdev