I need some simple include() help

Discussion in 'PHP' started by carljohn, May 8, 2007.

  1. #1
    Here's the file i have

    header.html

    footer.html

    index.html (my main page content)
    <?php include("header.html"); ?>
    content
    <?php include("footer.html"); ?>

    movie.html
    <?php include($_SERVER[‘DOCUMENT_ROOT’].”/header.html”); ?>
    content
    <?php include($_SERVER[‘DOCUMENT_ROOT’].”/footer.html”); ?>

    index.php
    <?php
    include('index.htm');
    ?>


    My index.html was able to get the header & footer code. But the movie.html can't get the php code. Can anyone fix this for me. Thanks
     
    carljohn, May 8, 2007 IP
  2. canadiankits

    canadiankits Peon

    Messages:
    125
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #2
    canadiankits, May 8, 2007 IP
  3. TwistMyArm

    TwistMyArm Peon

    Messages:
    931
    Likes Received:
    44
    Best Answers:
    0
    Trophy Points:
    0
    #3
    You say your index.html file doesn't have a problem running the PHP but is that because it doesn't have a problem or because you're either explicitly or implicitly running it through index.php first? If you run it through index.php first, it's getting picked up by the PHP parser and all is well. You can be certain by explicitly access index.html through your browser. Does that work? If so, I don't know what the problem is but if not, it's because your HTML files are not being processed by PHP (which is the default behaviour).

    I would either just rename movie.html to movie.php or add a line in your htaccess file to make your HTML files be processed by PHP.
     
    TwistMyArm, May 9, 2007 IP
  4. NoamBarz

    NoamBarz Active Member

    Messages:
    242
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    58
    #4
    It seems to me that the movie.html file is an HTML file. HTML file's cannot use php includes, as far as I know. If you name it movie.php, it'll work. The reason your index file works is because you're loading it through the index.php file - a php file and not an HTML file. Hope this helps.
     
    NoamBarz, May 9, 2007 IP