Include failed

Discussion in 'PHP' started by dawggone, Oct 20, 2005.

  1. #1
    For months now I have been using include statements on my php pages to pull in files from my main site, these include:

    http://renaissancewomanonline.com/ads/announce.php
    http://renaissancewomanonline.com/ezines.php
    http://renaissancewomanonline.com/copyrightnotice.php

    Obviously makes it easier to make changes across several web sites.

    Today though suddenly the command that has been working

    <? include("http://renaissancewomanonline.com/copyrightnotice.php"); ?>

    isn't working now.

    The short version:

    <? include("copyrightnotice.php"); ?>

    works on the main site but the longer version doesn't work on any site that I've found. Here's an example of the horrible results: http://funtriviaonline.com

    Why would this happen, does anyone have an explanation and fix for me?

    I would be pathetically grateful! My poor allergy-befuddled brain can't think of one solution
     
    dawggone, Oct 20, 2005 IP
  2. durango

    durango Guest

    Messages:
    83
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I've had this issue happen to me before when the hosting company made a change to the firewall that denied access from the web server to all external ports. I guess they wanted to crack down on hackers gaining control of a webserver and doing nasty stuff from it.

    That's my first thought.
     
    durango, Oct 20, 2005 IP
  3. Lpspider

    Lpspider Well-Known Member

    Messages:
    2,216
    Likes Received:
    56
    Best Answers:
    0
    Trophy Points:
    160
    #3
    not sure if this is it, but this is what I use:

    
    
    <?php
    
    include 'home.php';
    
    ?>
    
    
    Code (markup):
     
    Lpspider, Oct 20, 2005 IP
  4. king_cobra

    king_cobra Peon

    Messages:
    373
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    0
    #4
    i have never used include to access a php file from an external domain. it never worked for me. coz include is supposed to include the code and u cant get the code that easy from an external domain.

    i dont think this long version will ever work. even if u made it work it will be a bad idea coz then anyone can just pull ur code from the site. it wont work though. i dunno how u made it work in the past. may be some permission setting will do the trick, but still...
     
    king_cobra, Oct 20, 2005 IP
  5. durango

    durango Guest

    Messages:
    83
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #5
    I don't think the idea is to include PHP code, because it would actually just include the HTML that is produced by the PHP script on the remote server.

    I think the best way of testing whether its a firewall issue is trying to use the CURL libraries to pull the HTML from the external server. If you have CURL available in your PHP installation. To check if you have the CURL libraries included in your installation, simply make a small php script that calls phpinfo(); and look at the results of that for CURL.

    
    <?php
    ob_start();
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, "http://renaissancewomanonline.com/copyrightnotice.php");
    curl_setopt($ch,CURLOPT_HEADER,FALSE);
    curl_exec($ch);
    curl_close($ch);
    $includedHTML = ob_get_contents();
    ob_end_clean();
    echo $includedHTML;
    ?>
    
    Code (Example):
    If the above does not work, then its more than likely a firewall issue not allowing the server to connect to the external site.
     
    durango, Oct 20, 2005 IP
  6. king_cobra

    king_cobra Peon

    Messages:
    373
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    0
    #6
    if its including the html code then the above is the best way. inlude is used to include the code and i cudnt think that he is using that to get the html code.
     
    king_cobra, Oct 20, 2005 IP
  7. sarahk

    sarahk iTamer Staff

    Messages:
    28,840
    Likes Received:
    4,542
    Best Answers:
    123
    Trophy Points:
    665
    #7
    The code is on a different domain but is it on a different hosting account?

    If it's the same hosting account then you can include by using the actual file path.

    To find out the path of the calling file use
    echo getcwd();
    PHP:
    and edit that into the include statement until you get your file.
     
    sarahk, Oct 21, 2005 IP
  8. dave487

    dave487 Peon

    Messages:
    701
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    0
    #8
    I had the same problem, its almost certainly the firewall on the server that needs setting up to allow access to the other domain.
     
    dave487, Oct 24, 2005 IP