I'm new to PHP first of all ..
My question is once I got the $result from Server1 using mysql_query , how can I create Table2 that would stored in host2
<?php
$connect1 = mysql_connect(host1,user,pass);
$selected = mysql_select_db(database1,$connect1);
$result = mysql_query("select a,b,c from table1");
$connect2 = mysql_connect(host2,user,pass);
$selected = mysql_select_db(database2,$connect2);
mysql_query("create table table2 as select $result from table2");
?>
They are two different servers (both in MySQL) .. answer in details would appreciated.
Thanks
mysql_query
accepts two parameters. The second is the connection, have you tried this?
mysql_query("create table table2 as select $result from table2", $connect2);
PHP Documentation on mysql_query
:
http://php.net/manual/en/function.mysql-query.php
mysql
is a dinosaur that's on the way out. You'll be much better served using one of the other methods I've mentioned - rdlowrey 2012-04-05 00:19