1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

accessing remote pages

Discussion in 'PHP' started by vijaykoul, Oct 3, 2005.

  1. #1
    Hi frnds,

    I have a problem accessing pages from some remote sites.
    is there any way to do the same.
    i will be highly thankful.....if somebody helps me sort out this matter

    thanks in advance
    SEMrush
    whitedust
     
    vijaykoul, Oct 3, 2005 IP
    SEMrush
  2. draculus

    draculus Peon

    Messages:
    63
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You don't state whether it is the coding that you want, to be able to acheive your goal, or whether you know that but it doesn't work.

    Code examples or the error messages you are getting would help.
     
    draculus, Oct 3, 2005 IP
  3. vijaykoul

    vijaykoul Guest

    Messages:
    43
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    i have two websites on two different servers.
    i have database on one of the server and i want to access that databse from another server. i have got the file on the server where i have the database. now i want to access the same file feom the anothe website hosted on another server. i included the file using absolute path of the file, but the file is not executing.

    i specified the following path

    include("http://www.domainname.com/filename.php");
    it is not working

    please help

    it is urgent
     
    vijaykoul, Oct 3, 2005 IP
  4. Smyrl

    Smyrl Tomato Republic Staff

    Messages:
    13,619
    Likes Received:
    1,642
    Best Answers:
    78
    Trophy Points:
    510
    #4
    Could you have set server with database to disallow hotlinking?

    Shannon
     
    Smyrl, Oct 3, 2005 IP
  5. SecondV

    SecondV Active Member

    Messages:
    76
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    70
    #5
    Hmm, not sure what you're trying to do... But possibly:

    
    
    $page = file_get_contents("http://www.domainname.com/filename.php");
    echo $page;
    
    
    PHP:
     
    SecondV, Oct 3, 2005 IP
  6. dave487

    dave487 Peon

    Messages:
    701
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    0
    #6
    If your server has a firewall you will need to set it so that you can connect to the external site.
     
    dave487, Oct 3, 2005 IP
  7. FeedBucket

    FeedBucket Well-Known Member

    Messages:
    159
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    108
    #7
    Try using curl.
     
    FeedBucket, Oct 3, 2005 IP
  8. boccio

    boccio Peon

    Messages:
    82
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #8
    cURL or anything else won't help if the server is configured not to accept connections to MySQL from outside...
     
    boccio, Oct 4, 2005 IP
  9. johnt

    johnt Peon

    Messages:
    178
    Likes Received:
    21
    Best Answers:
    0
    Trophy Points:
    0
    #9
    The include function works differently when using remote ( i.e.http://whatever ) paths than when using local paths. If you use a remote path then the script will execute on the remote server, and any variables that you are depending on being set in the script will not be available to you on the local machine. Also, any variables set in the local script will not be available to the remote script.

    If all you want to do is access a remote database, you just need to make sure that the database is ready to accept connections from your local server - e.g. you need a database user "dbuser" at host "myhost.com" ( or 111.222.333.444) set up in your users table. Then you can just connect as normal.
    (I'm assuming that you're using MySQL. If so you can set the user up through PHPMyAdmin and then just use mysql_connect() as normal. )
     
    johnt, Oct 4, 2005 IP