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.

Why is this include not working?

Discussion in 'PHP' started by Drew007, Jun 25, 2007.

  1. #1
    Hello. I have the following include that works just fine:

    <?php include("news.html"); ?>
    PHP:
    But when I try to include from another one of my sites, on a different domain, it doesnt work. Here is the sample code:

    <?php include('http://www.mysite.com/news.html'); ?> 
    PHP:
    Am I using the right code to grab the html from a diff domain? Thanks in advance.
     
    Drew007, Jun 25, 2007 IP
  2. b.a

    b.a Peon

    Messages:
    50
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You can use include() only locally.
    If you need only the content of the file you include, you can try this
    
    echo file_get_contents('http://www.mysite.com/news.html');
    
    PHP:
     
    b.a, Jun 25, 2007 IP
    Drew007 likes this.
  3. Drew007

    Drew007 Peon

    Messages:
    310
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thank you. Rep added & much appreciated.
     
    Drew007, Jun 25, 2007 IP
  4. UnrealEd

    UnrealEd Peon

    Messages:
    148
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #4
    not true: it depends on a setting in the php.ini file, named allow_url_fopen
    if it is set to 'On', you can include external scripts (i use it all the time). Some host companies turn it off, don't really now why, but wth :)
     
    UnrealEd, Jun 25, 2007 IP
    sawz likes this.
  5. Drew007

    Drew007 Peon

    Messages:
    310
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Thanks for everyone's input. OK, here is the tough part. I have successfully included html from another domain.

    Now within that html file, I would like to include several pages.

    Why? I am providing hosting in a niche market and need to automatically update their site each month with this very specific content provided by me. I dont know databses so this is the only way I can think to do it.

    Does this make sense? Thanks in advance.
     
    Drew007, Jun 26, 2007 IP
  6. UnrealEd

    UnrealEd Peon

    Messages:
    148
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #6
    change the extension from the html page to php, and use the same include function to include the other pages.
     
    UnrealEd, Jun 28, 2007 IP