. How can i access a DB on server B from sites on server A?

Discussion in 'PHP' started by rapdancer, Nov 26, 2007.

  1. #1
    I have 2 different sites located on server/hosting "A" which need to connect to a DB on hosting "B".

    Both hostings originally offer the "localhost" option. How can i access a DB on server B from sites on server A?


    $dbh=mysql_connect ("IP-of-server1:localhost?", "username", "password");
    mysql_select_db ("databasename");

    Can anyone give me an advice on what should be put instead of "localhost"? thanks.
     
    rapdancer, Nov 26, 2007 IP
  2. selling vcc

    selling vcc Peon

    Messages:
    361
    Likes Received:
    18
    Best Answers:
    0
    Trophy Points:
    0
    #2
    $dbh=mysql_connect ("IP-of-server1", "username", "password");
    or
    $dbh=mysql_connect ("Domain-name-of-server1", "username", "password");

    I guess...

    Link : helpdesk.hostmonster.com/kb/index.php?x=&mod_id=2&id=291
     
    selling vcc, Nov 26, 2007 IP
  3. Barti1987

    Barti1987 Well-Known Member

    Messages:
    2,703
    Likes Received:
    115
    Best Answers:
    0
    Trophy Points:
    185
    #3
    Put the IP address or domain name instead of localhost.

    Insure that you allow host a to connect from host b using mysql permissions.

    Peace,
     
    Barti1987, Nov 26, 2007 IP