SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member
    Join Date
    Feb 2009
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Connect to MySQL Database

    I know how to connect to a local database, but is there anything special I have to do to connect to a database on a different domain.

    Here's what I have:

    $host = "localhost";
    $user = "phpuser";
    $password = "secret";
    $dbname = "OnlineOrders";

    $cxn = mysqli_connect($host,$user,$password,$dbname);

  2. #2
    Theoretical Physics Student bronze trophy Jake Arkinstall's Avatar
    Join Date
    May 2006
    Location
    Lancaster University, UK
    Posts
    7,062
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Nope, just change "localhost" to the external server address.
    Jake Arkinstall
    "Sometimes you don't need to reinvent the wheel;
    Sometimes its enough to make that wheel more rounded"-Molona

  3. #3
    SitePoint Member
    Join Date
    Feb 2009
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I changed $host = "localhost"; to

    $host = "mysql,mocorunning,com/";

    which is what i type in to get to the database.
    yet I get this error:


    Warning: mysql_connect() [function.mysql-connect]: Unknown MySQL server host 'mysql,mocorunning,com/' (1) in /home/welovewe/public_html/mdavis/Untitled-1,php on line 17

    LINE 17:
    $cxn = mysql_connect($host, $user, $password, $dbname);

  4. #4
    Web Professional
    Join Date
    Oct 2008
    Location
    London
    Posts
    862
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    $host "mysql.mocorunning.com"


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •