How insert in table from another database MYSQL


This Content is from Stack Overflow. Question asked by higashikata

I have a table in a hosting I want to communicate with it remotely through my localhost, but I can’t reference that I want the table from that database how do I do that?

*im using php *


// Create connection

$conn = mysqli_connect('localhost', 'root', '','contador');
$conn2 = mysqli_connect('hostingIP', 'userIp', 'userPass');
$result = mysqli_query($conn2,$dbname2);

$sql = "INSERT INTO tab2 (Data,Acessos) VALUES ( now(),(SELECT COUNT(*) FROM $result.$tableName WHERE DATE(Data)= CURRENT_DATE() - INTERVAL 0 DAY))";



Check the Answers

This Question and Answer are collected from stackoverflow and tested by JTuto community, is licensed under the terms of CC BY-SA 2.5. - CC BY-SA 3.0. - CC BY-SA 4.0.

people found this article helpful. What about you?