Dear all,
I have two identical mysql server with same databases and tables structures but with different data.
ServerA ServerB
Database Shaqib Database Shaqib
Table users Table users
ID | Name | Phone ID | Name | Phone
1 |Test1 | 123456 1 |Test13 | 1256456
2 |Test2 | 785632 2 |Test14 | 8621038
3 |Test3 | 985632 3 |Test15 | 7841308
I want to query both tables and out all the data in a single xml file.
Below is my database connection and query
$host1 = "10.0.1.1";
$user1 = "test";
$pass1 = "test";
$database1 = "shaqib";
$linkID1 = mysql_connect($host1, $user1, $pass1) or die("Could not connect to host.");
mysql_select_db($database1, $linkID1) or die("Could not find database.");
$query1 = "SELECT phone, name FROM users ORDER BY name ASC";
//$resultID1 = mysql_query($query1, $linkID1) or die("Data not found.");
//Margarine settings
$host2 = "10.0.1.2";
$user2 = "test";
$pass2 = "test";
$database2 = "shaqib";
$linkID2 = mysql_connect($host2, $user2, $pass2) or die("Could not connect to host.");
mysql_select_db($database2, $linkID2) or die("Could not find database.");
$query2 = "SELECT phone, name FROM users ORDER BY name ASC";
//$resultID2 = mysql_query($query2, $linkID2) or die("Data not found.");
//Merge both phonebook
$query = $query1." ".UNION." ".$query2;
$resultID = mysql_query($query);
$xml_output = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
$xml_output .= "<AddressBook>\n";
$xml_output .= "<version>1</version>\n";
for ($x = 0; $x < mysql_num_rows($resultID); $x++) {
$row = mysql_fetch_assoc($resultID);
when i run this query, i got a blank xml file..
Can someone help me.