php - Communication between the two servers to transfer data -
why can not establish connection!! how create relationship between 2 tables in 2 database on separate server information in fact, want records table in second server , insert server in table table selection correct:site1.com.class.users
this code:
$conn_server1=mysql_connect("site1.com","user","pass"); $db_server1=mysql_select_db("class",$conn_server1); $conn_server2=mysql_connect("site2.com","user","pass"); $db_server2=mysql_select_db("class",$conn_server2); $result=mysql_query("select * site2.com.class.users site2.com.class.users.mobile not in(select mobile form site1.com.class.users)",$conn_server1); while(mysql_fetch_assoc($result)) mysql_query("insert site1.com.class.users(name,family,phone1,phone2,mobile) select name,family,phone1,phone2,mobile site2.com.class.users",$conn_server1); site2.com.class.users",$conn_server1);
you trying select data connection 1 while using connection 2. that's not going work. , while @ it. might want using mysqli / pdo instead of marked deprecated mysql extension.
$res_server = mysql_query("select name, family, phone1, phone2, mobile users", $conn_server2); while($row = mysql_fetch_assoc($res_server)) { // update / insert on $conn_server1 }
Comments
Post a Comment