[email protected] Posted February 3, 2010 Share Posted February 3, 2010 Hello, I m trying to create a new table on server B as like a table on server A in php script. The steps I did are, 1. Using mysql_connect() and mysql_select_db() I established connection on Server A & B with 2 different variable sets, say variable $db1 holds the db of Server A and variable $db2 holds the db of Server B. 2. Tables are list from both the DBs 3. Needed to create missing tables on Server B [ie., copy missed tables with rows from server A to Server B]. Here, it is struggling................ How to create or copy a specific table from one server to another server or IP in PHP ??? Can anybody help?????? Its urgent. Thanks in advance. Link to comment https://forums.phpfreaks.com/topic/190774-managing-multiple-php-mysql-connections/ Share on other sites More sharing options...
Mchl Posted February 3, 2010 Share Posted February 3, 2010 Easiest thing to do would be to attach tables from server A to server B using FEDERATED engine http://dev.mysql.com/doc/refman/5.0/en/federated-storage-engine.html Link to comment https://forums.phpfreaks.com/topic/190774-managing-multiple-php-mysql-connections/#findComment-1006005 Share on other sites More sharing options...
[email protected] Posted February 3, 2010 Author Share Posted February 3, 2010 Thank u. But already Server A and Server B has lot of tables, only few are missing.. How to change them all now as federated.. ? Can u give the query to copy a table from Server A to B if it is federated..? Link to comment https://forums.phpfreaks.com/topic/190774-managing-multiple-php-mysql-connections/#findComment-1006029 Share on other sites More sharing options...
Mchl Posted February 3, 2010 Share Posted February 3, 2010 First create a table with same structure residing on server B THen do INSERT INTO tableOnB SELECT * FROM tableFederatedFromA Link to comment https://forums.phpfreaks.com/topic/190774-managing-multiple-php-mysql-connections/#findComment-1006032 Share on other sites More sharing options...
[email protected] Posted February 5, 2010 Author Share Posted February 5, 2010 :'( Can anybody having solution to my problem...? How to create table on remote mysql server??????? Link to comment https://forums.phpfreaks.com/topic/190774-managing-multiple-php-mysql-connections/#findComment-1007204 Share on other sites More sharing options...
[email protected] Posted February 5, 2010 Author Share Posted February 5, 2010 Here is my code: <?php #Staging $hostname='localhost'; $un= 'admin'; $pwd='******'; $db='instglive'; $link=mysql_connect($hostname, $un, $pwd); if(!$link) die('Could not connect: ' . mysql_error()); if(!mysql_select_db($db,$link)) die('Could not link db: ' . mysql_error()); #Live $hostname1='222.666.73.91'; $un1= 'test'; $pwd1='*******'; $db1='testdb'; $link1=mysql_connect($hostname1, $un1, $pwd1); if(!$link1) die('Could not connect: ' . mysql_error()); if(!mysql_select_db($db1,$link1)) die('Could not link db: ' . mysql_error()); $d="CREATE TABLE ".$db1.".".student." LIKE ".$db.".".student"; if(!mysql_query($d)) echo mysql_error(); ?> I need to work out the create table query on instglive db... anybody there to help???? Link to comment https://forums.phpfreaks.com/topic/190774-managing-multiple-php-mysql-connections/#findComment-1007205 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.