php includes

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jobe
    Member
    • Oct 2004
    • 50

    #1

    php includes

    Excuse my ignorance on this but can ssi - includes - post up images when asked for. In the header file - nothing else but:

    <div align="center"><img src="/images/gensite/head.gif" width="480" height="86"></div>

    In the document - a page from a DW template:
    <?
    require ("includes/header.php");
    ?>

    The alt tag shows but not the image itself - when loading you see the outline of the image & then it goes. The same happens with the navigation bar. The page is an .htm one.
    I'm new to includes. Any ideas gratefully received. Thanks.
    Last edited by jobe; 03-07-2005, 01:42 PM.
  • Stu Wilson
    Junior Member
    • Jun 2004
    • 4

    #2
    you are getting confused between server side includes and PHP parsed includes.

    if you save your file with the php include in, as a php file it will get parsed correctly and the image will be seen.

    If it has to stay as html, then the include file needs to have the PHP tags removed (well not really they will be ignored by the web page but will break any XHTML compliance)

    and the include will have to change to a SSI type include which if memory serves is in the form.

    <!-- #include "myincludefile.html" -->

    Comment

    • jobe
      Member
      • Oct 2004
      • 50

      #3
      Thanks for getting back to me.
      I'm trying all kinds of permutations but not having much luck. Before with the .htm file & the php includes I was seeing the search box include fine, & the text for the nav bar & the footer.
      Now with the .htm page & the <!--#include virtual="/includes/navbar.html" --> DW type includes I'm not seeing any of the includes.

      Do you think it might be a server thing?

      Comment

      • DesignURL
        Junior Member
        • May 2004
        • 19

        #4
        Check the path of the image in the header.php file. Although the header.php is in the /includes/ directory, when it is included in a file at your root directory, it looks for the path of the image from that location, not the /includes/ directory.

        To be sure, load the page in your browser from your server, then view the source and note where the image path is. You may have to alter it in your header.php file.

        Comment

        • jobe
          Member
          • Oct 2004
          • 50

          #5
          Something very strange going on - no includes showing, let alone the images. All is up as seen in the file manager as well but no show.
          Will have to leave it - night here & time to knock off. Will let you know how I get on. Thanks.

          Comment

          • -Oz-
            Senior Member
            • Mar 2004
            • 545

            #6
            why not try:
            Code:
            <?php 
            include($_SERVER['DOCUMENT_ROOT'] . "/includes/header.php");
            ?>
            That should do the trick. and it will work on all the documents in any folder across your site.

            Also, make sure the file this is being put in is a .php, so for example index.php could include this reference to a header. For ssi you need .shtml.
            Dan Blomberg

            Comment

            Working...