我使用的是两个域名('域名1','域名2')和2个服务器('服务器A'以及'服务器B&#39 )。 ' domain1的'是主域名。 ' domain2',我用作后端,用于存储数据。因此数据将存储在服务器B中。当我使用' domain1'在浏览器中,它将显示存储在服务器B'中的数据。 。我没有使用服务器A'
我做了一些代码。请仔细阅读,让我知道我必须做的更正。代码如下,
//these hostname,dbname,user and password from server B,(is this correct?)
$hostname = "1.1.1.1" ;
$database = "db_B" ;
$user = "u_B" ;
$pasword = "u_pas" ;
$conn = mysqli_connect($hostname,$user,$pasword,$database) ;
if (!$conn)
{
die ("Error connecting to the database because : " .
mysqli_error($conn)) ;
}
答案 0 :(得分:0)
In domain1 config.php file i have written the following code. It's working for me.
$servername = "domain2.in" ;
$database = "db_B" ;//server B's database name
$user = "u_B" ;//server B's database's(db_B) user name
$pasword = "u_pas" ;//server B's database's(db_B) password
$conn = mysqli_connect($servername,$user,$pasword,$database) ;
if (!$conn)
{
die ("Error connecting to the database because : " .
mysqli_error($conn)) ;
}
after this, add "server A"'s Remote MySQL hostname in "server B"'s Remote MySQL.