Include function problem

Discussion in 'PHP' started by chicago24, Mar 24, 2011.

  1. #1
    Hi,

    I am trying to include my menu and header on my website. It seems to be picking up the pictures but not showing them.

    My code is:
    
    <?php 
    include ("..\head.html"); 
    ?> 
    
    <table border="0" width="100%" cellspacing="0" cellpadding="2">
    <tr>
    <td valign="top" align="left" width="90">
    
    <?php 
    include ("..\menu.html");
    ?>
    
    PHP:
    My file structure is like this:
    FILE menu.php
    FILE head.php
    FOLDER blog - FILE index.php(where the code came from)
    FOLDER Images

    The menu and head files all link to the images folder, it is showing me the name of the image but just a little red cross.

    I hope that explains it ok. I don't knwo if i'm just missing something simple. Can anyone help? :)
     
    chicago24, Mar 24, 2011 IP
  2. thomasdgr

    thomasdgr Active Member

    Messages:
    167
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    60
    #2
    As you say your files are head.php and menu.php.

    So you have to include those files and not head.html and menu.html

    The two php lines should be the following

    include ("..\head.php");
    include ("..\menu.php");
     
    thomasdgr, Mar 24, 2011 IP
  3. chicago24

    chicago24 Peon

    Messages:
    10
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Sorry I didn't mean .php I meant .html mistake by me there. Any other reasons you can think of for it not showing the images?
     
    chicago24, Mar 24, 2011 IP
  4. thomasdgr

    thomasdgr Active Member

    Messages:
    167
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    60
    #4
    Use slash and not backslash

    include ("../head.php");
    include ("../menu.php");

    If it does not work either, then use the real path of the files.
     
    thomasdgr, Mar 24, 2011 IP
  5. chicago24

    chicago24 Peon

    Messages:
    10
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    It's in a lower directory that why I put ..\ I tried ../ but that didn't work either. Any other ideas? :)
     
    chicago24, Mar 24, 2011 IP
  6. thomasdgr

    thomasdgr Active Member

    Messages:
    167
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    60
    #6
    Use the full path.
     
    thomasdgr, Mar 24, 2011 IP
  7. bledileka

    bledileka Peon

    Messages:
    35
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #7
    if you see that the files are called but images are not shown than check image paths on your head and menu files. put a slash to be sure your getting them from the root domain like : /images/image.jpg
     
    bledileka, Mar 24, 2011 IP
  8. chicago24

    chicago24 Peon

    Messages:
    10
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    I have used the head and menu files in other files in the same folder as them and they have worked fine which is why its confusing me?

    thomasdgr I have tried using the full path as well and it still didn't work.

    Thanks :)
     
    chicago24, Mar 24, 2011 IP
  9. G3n3s!s

    G3n3s!s Active Member

    Messages:
    325
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    80
    #9
    you mix php & html things together :p
    it's not necessary

    OP: put here your head.html ;)
     
    G3n3s!s, Mar 25, 2011 IP
  10. chicago24

    chicago24 Peon

    Messages:
    10
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #10
    This is my head.html code:
    
    <html>
    <body>
    <div id="wrapper">
    <table height="80" width="100%" cellpadding="0" cellspacing="0" border="0">
    <tr><td align="centre" valign="bottom" width="160" rowspan="2">
    <a href="1.homepage.php">
    <img src="Images/newheading.gif" width="978" height="180" alt="Bassett Green">
    </a></td>
    </tr></table>
    
    <div align="right">
    <?php
    echo date("l F d, Y");
    ?>
    </div>
    
    <div align="left">
    <a href="http://home.healthyschools.gov.uk/"><img src="Images/healthy_schools.png" alt="Healthy Schools"></img></a>
    <a href="http://www.teachernet.gov.uk/teachingandlearning/subjects/pe/"><img src="Images/active_mark.png" alt="Active Mark"></img></a>
    <a href="http://www.investorsinpeople.co.uk/Pages/Home.aspx"><img src="Images/investor_in_people.png" alt="Investors In People"></img></a>
    <a href="http://www.nationalcollege.org.uk/"><img src="Images/ncsl.png" alt="NCSL"></img></a>
    <a href="http://www.artscouncil.org.uk/"><img src="Images/arts_council.png" alt="Arts Council England"></img></a>
    </div>
    </br>
    
    PHP:
    It's confusing me as the head.html and menu.html work fine with other files that are in the same folder as them. It's obviously picking them up just no the picture. Thanks for looking :)
     
    chicago24, Mar 26, 2011 IP