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 Quote Link to comment 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"); Quote Link to comment 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(); ?> Quote Link to comment Share on other sites More sharing options...
gevans Posted January 17, 2009 Share Posted January 17, 2009 is layout.php in a folder? Quote Link to comment 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? Quote Link to comment 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? Quote Link to comment 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? Quote Link to comment 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 Quote Link to comment 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" Quote Link to comment 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 \\ Quote Link to comment 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.