By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,985 Members | 1,776 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,985 IT Pros & Developers. It's quick & easy.

selecting values from a table of one server to insert them into another server by php

P: 3
hi all i have two servers each having a table in them, i'm able to connect to them using php. But when i try to select the values from one table of a server to insert them into another table in another server that is not working even i had given all the privileges can one show me how to do that.....


Expand|Select|Wrap|Line Numbers
  1. <?php
  2.  
  3. $dblink2 = mysql_pconnect('test1.deftlogic.com', 'dtestone_ipab','!*D-pD)g5)FJ'); // connect server 2
  4.  
  5. mysql_select_db('dtestone_db_2025', $dblink2);  // select database 2
  6.  
  7. echo $dblink2;
  8.  
  9. if(!$dblink2)
  10. {
  11.     echo "not connected";
  12. }
  13. else echo "db2 connected";
  14.  
  15. $dblink1 = mysql_connect('localhost', 'dtestfor_ipab','IaMzieU3#b%$'); // connect server 1
  16. mysql_select_db('dtestfor_IPAB_db',$dblink1);  // select database 1
  17.  
  18. if(!$dblink1)
  19. {
  20. echo "not connected";
  21. }
  22. else echo "db1 connected";
  23. echo "<br/>";
  24.  
  25. echo $dblink1;
  26.  
  27. $rs=mysql_query("INSERT INTO dtestfor_IPAB_db.bd_paidabribe (city, dept, amount) SELECT
  28.     SUBSTRING_INDEX(message, ',', 1),
  29.     SUBSTRING_INDEX(SUBSTRING_INDEX(message, ',', 2), ',', -1),
  30.     SUBSTRING_INDEX(message, ',', -1))as 'ma'
  31. FROM dtestone_db_2025.sms");
  32. ");
  33.  
  34. echo mysql_error();
  35. ?>
Apr 24 '12 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.