basic php / mysql question

Discussion in 'PHP' started by fgs, Mar 8, 2007.

  1. #1
    Is it possible to connect to two various mysql databases in one page.
    If it is, do you have to close connection with the first one before you do so?

    if it is possible could somebody please post a sample of code as to how to do it.

    thanks in advance
     
    fgs, Mar 8, 2007 IP
  2. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #2
    You can use different link identifiers. Like:
    
    
    $connection1 = mysql_connect('...');
    mysql_select_db('db', $connection1);
    
    $connection2 = mysql_connect('...');
    mysql_select_db('db2', $connection2);
    
    
    PHP:
    Now specify the link in your queries.
    
    mysql_query("SELECT * FROM table", $connection1);
    
    PHP:
     
    nico_swd, Mar 9, 2007 IP
    fgs likes this.
  3. fgs

    fgs Peon

    Messages:
    967
    Likes Received:
    22
    Best Answers:
    0
    Trophy Points:
    0
    #3
    absolutely awesome.... thanks so much, nice lil green guy for you
     
    fgs, Mar 9, 2007 IP