chokinz Posted January 9, 2014 Share Posted January 9, 2014 <?php $db_local_host = 'localhost'; $db_local_user = 'root'; $db_local_password = ''; $db_local_db = 'my_localdb'; $db_local_table = 'my_maintable'; $db_remote_host = 'http://www.mydomain.net/'; $db_remote_user = 'mydomain_admin'; $db_remote_password = 'mydomain_passwd'; $db_remote_db = mydomain_db'; $db_remote_table = 'my_maintable'; $dump = shell_exec("mysqldump -u{$db_local_user} -p{$db_local_password} --no-create-info --compact {$db_local_db} {$db_local_table}"); echo "Connecting to remote db...\n"; $link = mysql_connect($db_remote_host, $db_remote_user, $db_remote_password); if (!$link) { die('Could not connect to remote db: ' . mysql_error()); } echo "Connected successfully\n"; if (!mysql_select_db($db_remote_db, $link)) { die ("Can't connect to db {$db_remote_db}" . mysql_error()); } echo "Connected to db {$db_remote_db}\n"; $sql = "TRUNCATE TABLE {$db_remote_table}"; echo "Running query: {$sql}\n"; $res = mysql_query($sql) OR die(mysql_error()); echo $res ? "success\n": "failed\n"; echo "Running dump query\n"; $dump = str_replace("INSERT INTO `{$db_local_table}` ", "INSERT INTO `{$db_remote_table}` ", $dump); $dumps = explode("\n", $dump); $res = null; foreach ($dumps as $dump) { $dump = trim($dump); if($dump){ $res = mysql_query($dump) OR die(mysql_error()); } } $res = mysql_query($dump) OR die(mysql_error()); echo $res ? "success\n": "failed\n"; mysql_close($link); ?> Link to comment https://forums.phpfreaks.com/topic/285225-cant-sync-from-local-to-server-php_network_getaddresses-getaddrinfo-failed-no-such-host-is-known/ Share on other sites More sharing options...
chokinz Posted January 9, 2014 Author Share Posted January 9, 2014 btw, i'm using win8 64bit w/ xampp 1.8.1 Link to comment https://forums.phpfreaks.com/topic/285225-cant-sync-from-local-to-server-php_network_getaddresses-getaddrinfo-failed-no-such-host-is-known/#findComment-1464543 Share on other sites More sharing options...
kicken Posted January 9, 2014 Share Posted January 9, 2014 $db_remote_host should be just a hostname, not a URL. Link to comment https://forums.phpfreaks.com/topic/285225-cant-sync-from-local-to-server-php_network_getaddresses-getaddrinfo-failed-no-such-host-is-known/#findComment-1464601 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.