davykiash Posted January 17, 2009 Share Posted January 17, 2009 Hi Am a newbie using PHP Version 5.2.6. I am consitently getting this error Warning: include(/layout.php) [function.include]: failed to open stream: No such file or directory in E:\Tata\PHPSites\Membership\index.php on line 3 Warning: include() [function.include]: Failed opening '/layout.php' for inclusion (include_path='.;C:\php5\pear') in E:\Tata\PHPSites\Membership\index.php on line 3 Fatal error: Call to undefined function myheader() in E:\Tata\PHPSites\Membership\index.php on line 5 the files are existing in there respective directories. What am i missing? Thanks in Advance Link to comment https://forums.phpfreaks.com/topic/141235-failed-to-open-stream-no-such-file-or-directory-in-error/ Share on other sites More sharing options...
RichardRotterdam Posted January 17, 2009 Share Posted January 17, 2009 your include path is incorrect check if it reffers to the right folder include("layout.php"); Link to comment https://forums.phpfreaks.com/topic/141235-failed-to-open-stream-no-such-file-or-directory-in-error/#findComment-739212 Share on other sites More sharing options...
davykiash Posted January 17, 2009 Author Share Posted January 17, 2009 your include path is incorrect check if it reffers to the right folder include("layout.php"); This is the source file from which i am browsing <?php // include the layout file include $_SERVER['DOCUMENT_ROOT'].'/layout.php'; // Use the myheader function from layout.php myheader("Welcome to My Website!"); // Include the welcome html page. include $_SERVER['DOCUMENT_ROOT'].'/html/index_page.html'; // Use the footer function from layout.php footer(); ?> Link to comment https://forums.phpfreaks.com/topic/141235-failed-to-open-stream-no-such-file-or-directory-in-error/#findComment-739222 Share on other sites More sharing options...
gevans Posted January 17, 2009 Share Posted January 17, 2009 is layout.php in a folder? Link to comment https://forums.phpfreaks.com/topic/141235-failed-to-open-stream-no-such-file-or-directory-in-error/#findComment-739380 Share on other sites More sharing options...
davykiash Posted January 18, 2009 Author Share Posted January 18, 2009 is layout.php in a folder? When i use this superglobal i dont get the document root. <?php echo($_SERVER['DOCUMENT_ROOT']) ?> i think that is the problem. Am i missing some configuration settings? Link to comment https://forums.phpfreaks.com/topic/141235-failed-to-open-stream-no-such-file-or-directory-in-error/#findComment-739646 Share on other sites More sharing options...
PFMaBiSmAd Posted January 18, 2009 Share Posted January 18, 2009 Either $_SERVER['DOCUMENT_ROOT'] is not being set on your server or you have some code prior to what you posted that is overwriting it or a statement in a .htaccess file that is setting it to an empty value. Is the code you just posted to echo $_SERVER['DOCUMENT_ROOT'] the only code in the file? Link to comment https://forums.phpfreaks.com/topic/141235-failed-to-open-stream-no-such-file-or-directory-in-error/#findComment-739810 Share on other sites More sharing options...
davykiash Posted January 18, 2009 Author Share Posted January 18, 2009 Either $_SERVER['DOCUMENT_ROOT'] is not being set on your server or you have some code prior to what you posted that is overwriting it or a statement in a .htaccess file that is setting it to an empty value. Is the code you just posted to echo $_SERVER['DOCUMENT_ROOT'] the only code in the file? That is the only code in my script <?php echo($_SERVER['DOCUMENT_ROOT']) ?> Actually i ran up a search and i found it could be because i use IIS and ths is an apache thing. Could that be? Link to comment https://forums.phpfreaks.com/topic/141235-failed-to-open-stream-no-such-file-or-directory-in-error/#findComment-739815 Share on other sites More sharing options...
PFMaBiSmAd Posted January 18, 2009 Share Posted January 18, 2009 There is a doc_root = setting in php.ini that should be set under IIS to be to your IIS root folder, typically c:\Inetpub\wwwroot Link to comment https://forums.phpfreaks.com/topic/141235-failed-to-open-stream-no-such-file-or-directory-in-error/#findComment-739826 Share on other sites More sharing options...
davykiash Posted January 18, 2009 Author Share Posted January 18, 2009 There is a doc_root = setting in php.ini that should be set under IIS to be to your IIS root folder, typically c:\Inetpub\wwwroot i have changed the setting. The error has change from displaying nothing to "The page cannot be found" Link to comment https://forums.phpfreaks.com/topic/141235-failed-to-open-stream-no-such-file-or-directory-in-error/#findComment-739837 Share on other sites More sharing options...
PFMaBiSmAd Posted January 18, 2009 Share Posted January 18, 2009 Actual code? And what does echoing $_SERVER['DOCUMENT_ROOT'] show? You probably have a missing \ or too many of them \\ Link to comment https://forums.phpfreaks.com/topic/141235-failed-to-open-stream-no-such-file-or-directory-in-error/#findComment-739847 Share on other sites More sharing options...
davykiash Posted January 18, 2009 Author Share Posted January 18, 2009 Actual code? And what does echoing $_SERVER['DOCUMENT_ROOT'] show? You probably have a missing \ or too many of them \\ the code is that simple.only three lines. If u follow this topic u will realise i was zeroing down on a problem. <?php echo($_SERVER['DOCUMENT_ROOT']); ?> And i use IIS. Link to comment https://forums.phpfreaks.com/topic/141235-failed-to-open-stream-no-such-file-or-directory-in-error/#findComment-739853 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.