...

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



dj1mitch
05-06-2009, 02:49 AM
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!!!!!!!!


<?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

Fou-Lu
05-06-2009, 03:02 AM
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.

Hayyel
05-06-2009, 03:06 AM
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

dj1mitch
05-06-2009, 03:18 AM
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.

dj1mitch
05-06-2009, 03:18 AM
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.

abduraooft
05-06-2009, 08:43 AM
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?



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum