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



How can I retrieve values from one database server and store them in other database server using P..

Answer / 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

More PHP Interview Questions

Shopping cart online validation i.e. how can we configure Paypal, etc.?

1 Answers   INDUS,


Explain me what is the use of header() function in php?

0 Answers  


How to avoid the undefined index error?

0 Answers  


What is a definer in mysql?

0 Answers  


How can you associate a variable with a session?

0 Answers  


Is php outdated 2019?

0 Answers  


Create a PHP web script with the following attributes: on start, three HTML form elements are shown: an string input field, a checkbox field, a dropdown/pull down list with 5 elements and a submit button. On submission, the form should be redisplayed (while remaining all options/inputs as the user has selected/entered them). Additionally, the selections/inputs of the user should be displayed in text. Please solve this without the use of any external libraries.

1 Answers   Wipro,


Tell me how do I escape data before storing it into the database?

0 Answers  


How will you create a bi-lingual site (multiple languages) ?

3 Answers  


What is die in php?

0 Answers  


Php program to generate fibonacci series?

0 Answers  


What is the difference between associative array and indexed array?

0 Answers  


Categories