fer0an Posted October 20, 2010 Share Posted October 20, 2010 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? Quote Link to comment Share on other sites More sharing options...
Chris92 Posted October 20, 2010 Share Posted October 20, 2010 Just connect to the server. mysql_connect( 'website1', 'username', 'password') Quote Link to comment Share on other sites More sharing options...
fortnox007 Posted October 20, 2010 Share Posted October 20, 2010 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. Quote Link to comment Share on other sites More sharing options...
fer0an Posted October 20, 2010 Author Share Posted October 20, 2010 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: Quote Link to comment Share on other sites More sharing options...
fortnox007 Posted October 20, 2010 Share Posted October 20, 2010 $dbhost = "localhost"; i bet this is the troublemaker edit: maybe also want to just paste your error in google: a forum dealing with this same error is: http://drupal.org/node/129982 Quote Link to comment Share on other sites More sharing options...
fer0an Posted October 20, 2010 Author Share Posted October 20, 2010 no I changed it to website1 but I recived an error 2time. I think this problem with website2. any solution? Quote Link to comment Share on other sites More sharing options...
fortnox007 Posted October 20, 2010 Share Posted October 20, 2010 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.