Results 1 to 7 of 7

Thread: Including External files

  1. #1

    Thread Starter
    PowerPoster MidgetsBro's Avatar
    Join Date
    Oct 2000
    Location
    Apparently, Internet.com
    Posts
    3,125

    Including External files

    OK I have a PHP page where I want to include data from an external server. The php documentation says that this will work:
    PHP Code:
    include ("http://gah.stanford.edu/teams/HazteK_Software.html"); 
    But when I try it, I get a blank page. I want it to display my stats for Genome@Home, but this is not working. I don't want to have to use something like inline frames because it's not very compatible with anything other than IE, and I want to keep away from them anyway. I also don't want to link to an external page because I want it to look like it's part of my site.

    Thanks.
    <removed by admin>

  2. #2
    Fanatic Member cpradio's Avatar
    Join Date
    Apr 2002
    Posts
    616
    You cannot have http:// inside your include tag
    http://cpradio.net/
    Administrator @ WDForums and a Moderator @ WebXpertz City Forums

  3. #3

    Thread Starter
    PowerPoster MidgetsBro's Avatar
    Join Date
    Oct 2000
    Location
    Apparently, Internet.com
    Posts
    3,125
    Taken from here

    PHP Code:
    <?php

    /* This example assumes that [url]www.example.com[/url] is configured to parse .php *
     * files and not .txt files. Also, 'Works' here means that the variables *
     * $foo and $bar are available within the included file.                 */

    // Won't work; file.txt wasn't handled by [url]www.example.com[/url] as PHP
    include 'http://www.example.com/file.txt?foo=1&bar=2';

    // Won't work; looks for a file named 'file.php?foo=1&bar=2' on the
    // local filesystem.
    include 'file.php?foo=1&bar=2';

    // Works.
    include 'http://www.example.com/file.php?foo=1&bar=2';

    $foo 1;
    $bar 2;
    include 
    'file.txt';  // Works.
    include 'file.php';  // Works.

    ?>
    Why do they have it on their site and in their manual if it doesn't work??
    <removed by admin>

  4. #4
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    Windows versions of PHP prior to PHP 4.3 do not support accessing remote files via this function, even if allow_url_fopen is enabled.
    Is this you?
    My evil laugh has a squeak in it.

    kristopherwilson.com

  5. #5
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    And what is "allow_url_fopen" set to in your php.ini?
    My evil laugh has a squeak in it.

    kristopherwilson.com

  6. #6

    Thread Starter
    PowerPoster MidgetsBro's Avatar
    Join Date
    Oct 2000
    Location
    Apparently, Internet.com
    Posts
    3,125
    allow_url_fopen is set to on, but I just read that about the 4.3 problem this morning... I'll update it now, then see if it works.
    <removed by admin>

  7. #7
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256

    Re: Including External files

    Originally posted by MidgetsBro
    PHP Code:
    include ("http://gah.stanford.edu/teams/HazteK_Software.html"); 
    Just a side note: you don't need to surround the included file in ()'s. Just seems like a waste to me.
    My evil laugh has a squeak in it.

    kristopherwilson.com

Posting Permissions

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



Click Here to Expand Forum to Full Width