Connecting to SQL database in a different directory/server to website

Discussion in 'Technology' started by trance_fan, Oct 26, 2006.

Users Viewing Thread (Users: 0, Guests: 0)

  1. trance_fan

    trance_fan Registered User

    Joined:
    Nov 7, 2002
    Messages:
    9,079
    Likes Received:
    0
    Connecting to SQL database in a different directory/server to website

    Scenario....

    PHP pages are on one server, in a directory under my user account. (ie. http:\\server\myaccount

    MySQL database is on a different server, under phpmyadmin (ie, http:\\otherserver\phpmyadmin

    Just wondering how I should be connecting to MySQL database?

    I assume that "$hostname" will not be "localhost" and should infact be the url that the database is on, and then have the database name, username and password for it?

    Cheers
  2. 1615634792921.png
  3. Phil Mitchell

    Phil Mitchell check me a dollar brer?

    Joined:
    May 19, 2005
    Messages:
    8,965
    Likes Received:
    1
    Location:
    Melbourne
    i know the answer to this but its on my laptop at home and i havent got the internet at home

    sorry :lol:
  4. Jason Bourne

    Jason Bourne Registered User

    Joined:
    Oct 14, 2002
    Messages:
    5,337
    Likes Received:
    0
    Re: Connecting to SQL database in a different directory/server to website

    Your assumptions would appear to be correct..

    I imagine it would look something like this (this is asp though) -

    Hope that helps :)
  5. trance_fan

    trance_fan Registered User

    Joined:
    Nov 7, 2002
    Messages:
    9,079
    Likes Received:
    0
    that looks more like ASP to me Chandler!

    I just ended up using the IP address, and its as simple as

    $host = "<ip-address>"

    followed by your MySQL connect statements

    edit: missed the fact that you said it was ASP :lol:
  6. Jason Bourne

    Jason Bourne Registered User

    Joined:
    Oct 14, 2002
    Messages:
    5,337
    Likes Received:
    0
    :lol:

    As long as it worked :up:

Share This Page