top button
Flag Notify
Site Registration

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

+5 votes

I Know that we can always fetch from one database server and rewrite it to another. But what is the simplest way to do this?

posted May 1, 2014 by Sachin Dahda

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button
Simply retrieve data from one server and store it in session variables,  then connect to other server and insert the data into the database.

1 Answer

+1 vote

We have to connect to the database server from php using the mysql_connect and store the connection identifier in a variable and then fetch the data from the server and then close the server connections using mysql_close() and then connect to another server and insert the value there.

  1. Connected to the first server fetch the data and stored in the $res variable

    mysql_select_db("dtabase name",$db);
    $query="select * from the table";

  2. Connected to the second server

    mysql_select_db("dtabase name",$db);
    $query="insert into tablename values($res)";

answer May 3, 2014 by Rahul Mahajan
Similar Questions
0 votes

I have created a form which take in values like

i want to add these values into database, but i am having a problem in inserting the Image (photo).

+2 votes

how we can retrieve the unique values for the in a table without using the DISTINCT keyword