Jump to content

insert data from one website to another website


fer0an

Recommended Posts

hello

My database is in a same server with seperate domain name , then I want to insert from website1 mysql data on website2 mysql data.

can anyone help me?

 

It should be no different that a normal database connection within the same domain except for instead of using 'localhost' you use the external host.

I'm using this codes :

// Connecting, selecting database website 1

$dbuser = "test";
$dbpass = "test";
$dbhost = "localhost";
$dbname = "test";
$con = mysql_connect($dbhost, $dbuser, $dbpass)
   or die('Could not connect: ' . mysql_error());
mysql_select_db($dbname) or die('Could not select database');



// Connecting, selecting database website 2

$dbuser1 = "add";
$dbpass1 = "add";
$dbhost1 = "website2.com";
$dbname1 = "add";
$con1 = mysql_connect($dbhost1, $dbuser1, $dbpass1)
   or die('Could not connect: ' . mysql_error());
mysql_select_db($dbname1) or die('Could not select database');

and I recived an error :

 

Warning: mysql_connect() [function.mysql-connect]: Lost connection to MySQL server at 'reading initial communication packet', system error: 111 in /home/.... on line 22

Could not connect:

i have no idea what the naming protocol is, maybe ask the host in question? or maybe some real guru around here has an idea.

 

This though might be worth a try, it could be that your priviliges need to be fixed:

http://forums.mysql.com/read.php?108,62926,114663#msg-114663

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.