I would like to make a page for uploading some of my local records to the web server.
The Table Structure
from local and web server are the same.
My question is, how to connect to both server?
<?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);
?>
I got error for both local and web server.
Or is there another way for me to upload the local records to the 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: