Hello,

What I want to do is probably very simple but the script I just tried didn't work so I'll ask.

I want to create a footer and geader file that when I insert certain code on a page the footer and header will appear automatically. This is much like phpBB's overall_footer and overall_header system.

I tried this but nothing showed:

astjhsash

<?php
include&#40;"footer.php"&#41;;

?>

I want to put a copyright in my footer, and a banner and navbar in my header.

Thanks in advanced for help! 🙂

    did you make a footer.php file..?

      Yes. In the same directory as the index file.

        Did you rename the page that you put this code in to be a .php file?

        Does footer.php have PHP in it? Such as this:

        echo "<hr/>
        Copyright 2006 blah blah";

        If not, what did it look like?

          footer.php

          <?php
          echo '<div align="center"> &copy; Copyright Truestar Forums</div>' 
          ?>
          <?php
          
          echo '<div align="center"Hello!</div>'
          
          
          include("footer.php");
          ?>

          index.php

            Well, other than the HTML error in index.php, I don't see a problem... try fixing the HTML mistake (missing '>'), and if that doesn't work can you post a link to this page for us?

              You're missing two semicolons, but other that...it works for me.

                I've been using a uni.cc domain for testing.

                http://truestarforums.uni.cc

                hostcord, where wouldthose two semicolons go? I didn't realise they were missing.

                Nothing on the page even shows for me, no errors, text or anything.

                  Truestar wrote:

                  hostcord, where wouldthose two semicolons go? I didn't realise they were missing.

                  Check after every echo statement. Every statement in PHP has to be terminated by semicolons - it's not like Javascript.

                  Truestar wrote:

                  Nothing on the page even shows for me, no errors, text or anything.

                  That's probably because you've turned display_errors off, otherwise you'd be seeing some error text.

                    Truestar wrote:

                    footer.php

                    <?php
                    echo '<div align="center"> &copy; Copyright Truestar Forums</div>' 
                    ?>
                    <?php
                    
                    echo '<div align="center"Hello!</div>'
                    
                    
                    include("footer.php");
                    ?>

                    index.php

                    When did PHP start allowing double quotes inside single quotes?

                      The missing semicolon in the first file isn't an error, but it's a good idea to put it in anyway.

                      Like Brad said, if you turn on error display you'll see some output--an error message for that other missing semicolon. Edit: Also put in a closing angle bracket for the div.

                      When did PHP start allowing double quotes inside single quotes?

                      A long time ago.

                        Installer wrote:

                        The missing semicolon in the first file isn't an error, but it's a good idea to put it in anyway.

                        Like Brad said, if you turn on error display you'll see some output--an error message for that other missing semicolon.

                        A long time ago.

                        ..... Must of missed that announcement

                        Here I've been escaping or using heredoc for the last 2 years ...

                          I've altered the files and nothing still works.

                          index.php

                          <?php
                          $title = "<title>Truestar Forums</title>";
                          include&#40;"header.php"&#41;;
                          ?>
                          
                          <html>
                          <body>
                          <font>Hello!</font>
                          </html>
                          </body>
                          
                          <?php
                          include&#40;"footer.php"&#41;;
                          ?>

                          header.php

                          <html>
                          <head>
                          <title><?php echo $title; ?>Truestar Forums</title>
                          </head>
                          <body>

                          footer.php

                          &copy; This site and all its contents copyright 2006 <a href="http://truestarforums.com">Truestar Forums</a>
                          </body>
                          </html>

                            Okay,

                            I changed

                            include&#40;"footer.php");

                            To:

                            include('footer.php');

                            and everything worked out great! Thanks for the responses though. 🙂

                              Write a Reply...