hi all,
i want to update one field from one database to another database
my query is

mysql_connect('localhost', 'root', '') ;
mysql_select_db('db1');
mysql_connect('localhost', 'root', '') ;
mysql_select_db('db2');
$query1=mysql_query("select * from db1.tbl_products");
while($fetch=mysql_fetch_assoc($query1)){

echo "update db2.tbl_products set p_price='".$fetch['p_price']."' where p_id='".$fetch['p_id']."'";
echo "<br>";
echo "<br>";

}

in local it is executing correctly but in live error is diplaying
update acess denied for password@db2
any ideas

This should suffice, assuming your user has priviliges on both databases:

mysql_connect('localhost', 'root', '') ;
$query1=mysql_query("select * from db1.tbl_products");
while($fetch=mysql_fetch_assoc($query1)) { 
  echo "update db2.tbl_products set p_price='".$fetch['p_price']."' where p_id='".$fetch['p_id']."'";
  echo "<br>";
  echo "<br>";
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.