I would like to make a connection in php
on two databases only on different networks, in that connection I would need to search a database on a server and insert it into a table in a database on another server
For example:
$conecta = mysql_connect("rede1","usuario","senha");
$db = mysql_select_db("banco1");
and put a second connection:
$conecta1 = mysql_connect("rede2","usuario","senha");
$db = mysql_select_db("banco2");
// Here is where I do the query to fetch the data that will be stored in the variables
$serial = $_POST['serial'];
$query = mysqli_query("select coluna1 coluna2... from tabela1 where coluna 1 = '$serial'");
$result = mysqli_fecth_array($query);
$qry = $result['coluna2'];
For example:
$sql = mysqli_query($conecta,"select * from tabela1");
$result = mysqli_fetch_array($sql);
and with result of this query it makes an insert in a table in the database in the other server
$insert = mysqli_query(conecta1."insert into tabela2 values ('resultado da query acima')");
I know you can insert with the select inside for example:
$insert = mysqli_query($conecta1."insert into tabela2(".."select '$qry'... from tabela1) on duplicate key update coluna2 = values(coluna2)...");
I need to populate a database table from such a server and this padding will be the one from a select query where the data will be stored in a variable from a first select query
I did it this way but it did not work, does anyone know if there is a way to do this in php
? since then thank you.