SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Evangelist
    Join Date
    Oct 2000
    Posts
    430
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    I'm trying to include headers, footers and nav bars into my site using include();

    None of it seems to work and I hope someone could figure out why.

    The errors it is returning are:Warning: Failed opening '/Lib/banner_plus_humour_deal.htm' for inclusion (include_path='./:/usr/local/lib/php') in /home2/chilli/chillisauce-www/humour/weblinks2.php on line 11


    The include function is written like this:
    <? include("/Lib/menu_sports.htm"); ?>

    /Lib/ is one up from the route folder


    Could anyone tell me what the problem could be and how I could rectify it.

    Thanks for the help in advance.

  2. #2
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Use the absolute path from the root of the server or change the php include_path directive in the php.ini file or preferably use a .htaccess file and add

    php_value include_path "/fromroot/topath/to/startincludes/from"
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  3. #3
    SitePoint Evangelist
    Join Date
    Oct 2000
    Posts
    430
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Hi Freddie - cheers for the help

    So for the above I should use
    /home2/chilli/chillisauce-www/Lib/file_name?

    I like the sound of your advise RE: php.ini file, and .htaccess file, However I haven't a clue how these work or how to do it.

    Can you do either or both on a shared server? - and how easy is it to do?

    As I'm going to be doing a lot of "includes" what would be your prefered method - both performance wise and for ease of use?

    Cheers for the help.

  4. #4
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    On a shared server .htaccess is probably your only option. You can use it to change almost any of the values that you see when you do phpinfo(); Look for the include_path directive.
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  5. #5
    SitePoint Evangelist
    Join Date
    Oct 2000
    Posts
    430
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    I've created a .htaccess file with the function:
    php_value include_path "/home/chilli/chillisauce-www"

    This I thought, should point the include path to start at my root folder.

    However I get the following sorts of error when I try opening pages:


    Warning: Failed opening '/Lib/menu_active.htm' for inclusion (include_path='/home/chilli/chillisauce-www') in /home2/chilli/chillisauce-www/active/air_sports/index.php on line 17


    Is the problem that you cannot use directory paths within the include function?


    From the above error I can't see why it won't work as the constanation of the above include file path and the include path should open that file.

    ie /home/chilli/chillisauce-www . /Lib/menu_active.htm

    can anyone see a reason for this problem?



  6. #6
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try just Lib/menu_active.htm without the starting slash
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  7. #7
    SitePoint Evangelist
    Join Date
    Oct 2000
    Posts
    430
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    cheers - I'll have a go.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •