SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Zealot
    Join Date
    Sep 2005
    Posts
    129
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Mysql server to server

    First my apologies if this has been asked before but I am not quite sure how to search for the answer, if indeed, there is an answer.

    One thing I am sure of though, is if it is possible, someone on this forum will know the answer.

    Can i call the information from one of my mysql databases which is held on a different server to the script calling the information?

    for example I have a databse with a series of scores and league tables. I want to use this database to populate pages on 3 different websites which are held on their own domain name and server.

    At the moment i am calling a php file off the holding server into an iframe. This kind of does the job but it has its limitations with regard to styling, and the usual misgivings of using iframes.


    Hope this makes sense

    Thanks in advance

  2. #2
    Twitter: @AnthonySterling silver trophy AnthonySterling's Avatar
    Join Date
    Apr 2008
    Location
    North-East, UK.
    Posts
    6,111
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Sure, instead of 'localhost', just provide the remote IP or domain name of the other server.
    @AnthonySterling: I'm a PHP developer, a consultant for oopnorth.com and the organiser of @phpne, a PHP User Group covering the North-East of England.

  3. #3
    SitePoint Zealot
    Join Date
    Sep 2005
    Posts
    129
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    wow

    Thanks for the swift reply

    So does
    PHP Code:
    <?php

    /* servers config*/

    $hostname 'localhost';
    $username 'username';
    $password 'password';
    $table 'table name';

    ?>
    become

    PHP Code:
    <?php

    /* servers config*/

    $hostname 'remote IP or domain name';
    $username 'username';
    $password 'password';
    $table 'table name';

    ?>
    how is the domain name shown
    is it
    http://www.domainname.com
    or
    just www.domainname.com

    or is there a total different way to show it

    thanks again

  4. #4
    Twitter: @AnthonySterling silver trophy AnthonySterling's Avatar
    Join Date
    Apr 2008
    Location
    North-East, UK.
    Posts
    6,111
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    No problem, either of the following will work.

    PHP Code:
    <?php
    $rCon 
    mysql_connect('localhost');
    $rCon mysql_connect('127.0.0.1');
    $rCon mysql_connect('domain.com');
    $rCon mysql_connect('sql.domain.com');
    ?>
    @AnthonySterling: I'm a PHP developer, a consultant for oopnorth.com and the organiser of @phpne, a PHP User Group covering the North-East of England.

  5. #5
    SitePoint Zealot
    Join Date
    Sep 2005
    Posts
    129
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have tried all these and i get the same error

    Unknown MySQL server host

    Does the holding server have to have something done to it?

  6. #6
    Twitter: @AnthonySterling silver trophy AnthonySterling's Avatar
    Join Date
    Apr 2008
    Location
    North-East, UK.
    Posts
    6,111
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    It would need to have port 3306 open, or alternate specified one. Other than that, no, nothing else is required to connect.
    @AnthonySterling: I'm a PHP developer, a consultant for oopnorth.com and the organiser of @phpne, a PHP User Group covering the North-East of England.

  7. #7
    SitePoint Zealot
    Join Date
    Sep 2005
    Posts
    129
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ok thanks

    will try see how to make that happen

  8. #8
    SitePoint Wizard wheeler's Avatar
    Join Date
    Mar 2006
    Location
    Gold Coast, Australia
    Posts
    1,369
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i've often wondered, is there any security concerns with connecting to a remote server? Would the user/pass be susceptible to being intercepted?
    Studiotime - Time Management for Web Developers
    to-do's, messages, invoicing, reporting - 30 day free trial!
    Thomas Multimedia Web Development


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
  •