0

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

2
Contributors
1
Reply
3
Views
7 Years
Discussion Span
Last Post by pritaeas
0

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>";
}

Edited by pritaeas: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.