-4
I would like to make a connection on php
in two databases only that are in different networks, in this connection would need to do a search in a database on a server and insert in 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 as a result of this query makes an Insert in a table in the database on the other server
$insert = mysqli_query(conecta1."insert into tabela2 values ('resultado da query acima')");
i know you can do the Insert with 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 fill a database table of such a server and this fill will be coming from a query select, where the data will be stored in a variable coming from a first query select
I did it that way but it didn’t work, someone knows if it exists in php
a way to do it ? since then I thank you.
This is a matter of network and not PHP.
– Daniel Omine
I couldn’t use one comic at a time?
– Paul Polidoro