Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New to the CF scene
    Join Date
    May 2009
    Posts
    7
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Warning: require(header.php) [function.require]: failed to open stream: No such file

    I have a file header.php. I am attempting to call the file using "require or include". I get the below error in both instances.
    Please Help!!!!!!!!

    Code:
    <?php 
    require ('header.php');
    ?>
    Warning: require(header.php) [function.require]: failed to open stream: No such file or directory in C:\wamp\www\base\public_html\modules\contact.php on line 2

    Fatal error: require() [function.require]: Failed opening required 'header.php' (include_path='.;C:\php5\pear') in C:\wamp\www\base\public_html\modules\contact.php on line 2

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,978
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    This is what happens when you include files that have been included into other files from sub directories.
    Fix by changing all of you're include / require calls in every file to: require_once dirname(__FILE__) . '/../relative/path/to/include.php'; where this can be any type of require/include. The other option is to use an absolute path, which destroys you're portability.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  • #3
    New Coder
    Join Date
    Jan 2009
    Posts
    91
    Thanks
    17
    Thanked 1 Time in 1 Post
    Might be hard for me to explain...

    If you are trying to include header.php in a file and both are located in the root directory then try this:

    ../header.php

    If your header.php is in a folder then it would be:

    ../folder/header.php

    Like www.yoursite.com/index.php
    www.yoursite.com/pages/header.php

    Or two folders:

    folder/folder/header.php

    If the file is in a folder and header.php is in a previous folder then it is:

    ../header.php or ../../header.php

  • #4
    New to the CF scene
    Join Date
    May 2009
    Posts
    7
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Fou-Lu View Post
    This is what happens when you include files that have been included into other files from sub directories.
    Fix by changing all of you're include / require calls in every file to: require_once dirname(__FILE__) . '/../relative/path/to/include.php'; where this can be any type of require/include. The other option is to use an absolute path, which destroys you're portability.
    This is driving me crazy still not working, getting the same error.

  • #5
    New to the CF scene
    Join Date
    May 2009
    Posts
    7
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Hayyel View Post
    Might be hard for me to explain...

    If you are trying to include header.php in a file and both are located in the root directory then try this:

    ../header.php

    If your header.php is in a folder then it would be:

    ../folder/header.php

    Like www.yoursite.com/index.php
    www.yoursite.com/pages/header.php

    Or two folders:

    folder/folder/header.php

    If the file is in a folder and header.php is in a previous folder then it is:

    ../header.php or ../../header.php
    Nothing is working, thank you for trying.

  • #6
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,801
    Thanks
    160
    Thanked 2,216 Times in 2,203 Posts
    Blog Entries
    1
    I have a file header.php. I am attempting to call the file using "require or include". I get the below error in both instances.
    Please Help!!!!!!!!
    Could you post your directory structure along with the location of files here?
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)


  •  

    Posting Permissions

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