Php脚本从另一个数据库更新VIEW

I need to write a script which will take the values from two columns and use them to update the column in a view that I created in another database. In the first database I have sku and qty as well as in the view.

here is my code:

$server = 'localhost';
$user = 'invodata';
$pass = 'Abcd1234!1';
$dbname = 'tboinvodata';
$con = mysql_connect($server, $user, $pass) or die("Can't connect");
mysql_select_db("tboinvodata") or die(mysql_error());

 $result = mysql_query("SELECT item, onhand FROM immaster"); <- this is getting the values from     the columns in the first data base

 $server = 'localhost';<-setting up my second connection to other database
 $user = 'tbo';
 $pass = 'Abcd1234!1';
 $dbname = 'i187358_mage1';
 $con = mysql_connect($server, $user, $pass) or die("Can't connect");
 mysql_select_db("i187358_mage1") or die(mysql_error());

while ($row = mysql_fetch_array($result, MYSQL_NUM)) {<-this gets the array from other database

UPDATE qtyview SET qty = $row["onhand"] WHERE sku = item;<- this should update the necessary columns "sku" is used in my view and "item" is used in the first data base I use this so the proper rows in the other columns get updated. 
}

?>

really not sure what I am doing wrong I am pretty new to this though.

You can make multiple calls to mysql_connect() and use them like this.

First connect to two your MYSQL USER

$con1 = mysql_connect($server, $user, $pass); 
$con2 = mysql_connect($server, $user, $pass, true);

Then establish a connect with different DATABASE

mysql_select_db('firstdatabase', $con1);
mysql_select_db('seconddatabase', $con2);

Then query from firstdatabase like this

mysql_query('select * from views', $con1);

And query from seconddatabase

mysql_query('select * from views', $con2);

This code is not tested by me...but i think it will work good for you.. :)