logo

CuriousTab

CuriousTab

Discussion


Home Interview Technology Comments

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


  • Correct Answer
  • we can always fetch from one database and rewrite to another Here is a nice solution of it$db1 = mysql_connect("host","user","pwd") mysql_select_db("db1", $db1); $res1 = mysql_query("query",$db1);$db2 = mysql_connect("host","user","pwd") mysql_select_db("db2", $db2); $res2 = mysql_query("query",$db2);At this point you can only fetch records from you previous ResultSet, ie $res1 â?? But you cannot execute new query in $db1, even if you supply the link as because the link was overwritten by the new dbso at this point the following script will fail $res3 = mysql_query("query",$db1); //this will failSo how to solve that? take a look below $db1 = mysql_connect("host","user","pwd") mysql_select_db("db1", $db1); $res1 = mysql_query("query",$db1); $db2 = mysql_connect("host","user","pwd", true) mysql_select_db("db2", $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); 


  • Technology problems


    Search Results


    • 1. Will comparison of string "10" and integer 11 work in PHP?
    • Discuss
    • 2. With a heredoc syntax, do I get variable substitution inside the heredoc contents?
    • Discuss
    • 3. Difference between ActiveX Exe and Dll ?
    • Discuss
    • 4. Which of the following is not a function of a Warehouse?

    • Options
    • A. Ensuring Profit
    • B. Stabilisation in price
    • C. Risk-bearing
    • D. Storage
    • Discuss
    • 5. What is the difference between operational data stage (ODS) and data warehouse?
    • Discuss
    • 6. How to use HTTP Headers inside PHP? Write the statement through which it can be added?
    • Discuss
    • 7. Describe how to create a simple AD rotator script without using database in PHP.
    • Discuss
    • 8. What is the difference between the functions unlink and unset in PHP?
    • Discuss
    • 9. What is the difference between _construct() and _destruct() methods in php?
    • Discuss
    • 10. What's the difference between GET() and POST() method?
    • Discuss


    Comments

    There are no comments.

Enter a new Comment