我想制作一个页面,用于将我的一些本地记录上传到 Web 服务器。
从Table Structure
本地和 Web 服务器是相同的。
我的问题是,如何连接到两个服务器?
<?php
$localCon = mysql_connect("localhost", "root", "");
if (!$localCon) {
die('Could not connect: ' . mysql_error());
}
mysql_select_db("[table]", $localCon);
$serverCon = mysql_connect("mysql", "[username]", "[password]");
if (!$serverCon) {
die('Could not connect: ' . mysql_error());
}
mysql_select_db("[table]", $serverCon);
$result = mysql_query("SELECT * FROM [table]");
while ($row = mysql_fetch_array($result)) {
echo $row['[coloumn]'];
echo "<br />";
}
mysql_close($localCon);
mysql_close($serverCon);
?>
我的本地服务器和 Web 服务器都出现错误。
或者我有其他方法可以将本地记录上传到网络吗?
This is the error msg:
Warning: mysql_connect() [function.mysql-connect]: php_network_getaddresses: getaddrinfo failed: No such host is known. in [addres]
Warning: mysql_connect() [function.mysql-connect]: [2002] php_network_getaddresses: getaddrinfo failed: No such host is known. (trying to connect via tcp://mysql:3306) in [addres]
Warning: mysql_connect() [function.mysql-connect]: php_network_getaddresses: getaddrinfo failed: No such host is known. in [address]
Could not connect: