#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    22
    Rep Power
    0
    I'm trying to open 2 separate tables in 2 separate MySQL databases at one time. I've tried giving separate link identifiers, but for some reason, when the 2nd one is run, the first one seems to cancel. Is there anyway that I can have 2 database connections at once or do I have to do them both separately?
  2. #2
  3. No Profile Picture
    Apprentice Deity
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 1999
    Location
    Niagara Falls (On the wrong side of the gorge)
    Posts
    3,237
    Rep Power
    18
    Are both databases served from the same MySQL server or from different ones? You only make one connection to a server no matter how many databases you access from that server.

    If you are talking about 2 databases from the same server you do it this way:

    mysql_connect("host","user","pass");
    $result=mysql_db_query('db1',".. your query ..");
    $result2=mysql_db_query('db2'," .. other query");

    if you are talking two different servers you do it this way:

    $link1=mysql_connect("host1","user","pass");
    $link2=mysql_connect("host2","user","pass");
    mysql_select_db('dbname',$link1);
    mysql_select_db('otherdb',$link2);
    $result1=mysql_select('query here',$link1);
    $result2=mysql_select('other query',$link2);

Similar Threads

  1. Using Multiple Databases
    By CrazyeD in forum ASP Programming
    Replies: 2
    Last Post: February 16th, 2004, 07:41 PM
  2. Active perl multiple search when file is open
    By melinda in forum Perl Programming
    Replies: 3
    Last Post: January 28th, 2004, 04:29 AM
  3. which Open Source license to use?
    By joeymanley in forum Dev Shed Lounge
    Replies: 11
    Last Post: December 26th, 2003, 05:23 PM
  4. multiple databases
    By -PROJECT- in forum MS SQL Development
    Replies: 1
    Last Post: December 11th, 2003, 10:43 AM
  5. Replies: 1
    Last Post: December 11th, 2003, 02:13 AM

IMN logo majestic logo threadwatch logo seochat tools logo