PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Warning: main(/includes/mf/leftnav.php) [function.main]: failed to open stream: No such file or directory in c:\Inetpub\wwwroot\MySite\mf\index.php on line 13
Warning: main() [function.include]: Failed opening '/includes/mf/leftnav.php' for inclusion (include_path='.;C:\php5\pear') in c:\Inetpub\wwwroot\MySite\mf\index.php on line 13
I checked mutliple times the path and it is correct. I have tried this for the footer as well and I get the same error. I don't know if I'm doing anything wrong or maybe missing some permissions.
by using a preceding slash (/) you're indicating that the includes folder is at the root of the site.
I'd be willing to bet (given the path of your file) that it's not. If you the includes folder is relative to the file calling it, then you need to use a relative path to it.
Notice: Undefined index: DOCUMENT_ROOT in c:\Inetpub\wwwroot\MySite\mf\index.php on line 14
Warning: main(/includes/mf/leftnav.php) [function.main]: failed to open stream: No such file or directory in c:\Inetpub\wwwroot\MySite\mf\index.php on line 14
Warning: main() [function.include]: Failed opening '/includes/mf/leftnav.php' for inclusion (include_path='.;C:\php5\pear') in c:\Inetpub\wwwroot\MySite\mf\index.php on line 14
Would the error message show the actual path to the file that could not be included or the rewritten path?
I have never had a problem with declaring a variable in each page of my script called $page_root_path. I set that to path to the root directory and use that var for all of my includes. I have never had a problem with it.
<?php
$page_root_path = './'; // This file is located in http://www.mysite.com/ root
$page_root_path = './../'; // This file is located in http://www.mysite.com/somefolder/
$page_root_path = './../../'; // This file is located in http://www.mysite.com/somefolder/someotherfolder/
?>
So regardless of where your pages are on your server, your files will always point to root and your includes will always include from there.