How can I retrieve values from one database server and
store them in other database server using PHP?

Answer Posted / mahesh

$db1 = mysql_connect(”host”,”user”,”pwd”)
mysql_select_db(”db1name;, $db1);
$res1 = mysql_query(”query”,$db1);


$db2 = mysql_connect(”host”,”user”,”pwd”, true)
mysql_select_db(”db2name;, $db2);
$res2 = mysql_query(”query”,$db2);

So mysql_connect has another optional boolean parameter
which indicates whether a link will be created or not. as we
connect to the $db2 with this optional parameter set to
‘true’, so both link will remain live.

now the following query will execute successfully.
$res3 = mysql_query(”query”,$db1);

Is This Answer Correct ?    8 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How many types of php frameworks are there?

489


What is the difference between array_map () and array_shift ()?

516


Explain about PHP filter and why it should be used?

559


What is php and its features?

527


What is the use of mysqli_real_escape_string() function?

521






Which have the fastest execution between mysql_fetch_array() and mysql_fetch_assoc()

1821


How failures in execution are handled with include() and require() functions?

593


Code to open file download dialog in PHP?

552


Explain the advantages of using PHP?

555


How to include a file to a PHP page?

590


What are the advantages of stored procedures, triggers, indexes in php?

506


How can image properties be retrieved in php?

543


How can you get the size of an image in PHP?

548


A process can run only in the background. State Whether True or False?

624


Tell me what should we do to be able to export data into an excel file?

524