TapeGun007 Posted March 6, 2010 Share Posted March 6, 2010 I am using includes in the main directory. But when I call those includes in a sub folder ("admin" in this case), they simply do not work regardless of all the methods I've tried. Here is the path to root: \\boswinfs01\home\users\web\b406\ez.nancyholston I do this: <?php include "\\boswinfs01\home\users\web\b406\ez.nancyholston\components\Header.php" ?> I get this error: Warning: main(\boswinfs01\home\users\web\b406\ez.nancyholston\components\Header.php) [function.main]: failed to open stream: No such file or directory in \\boswinfs01\home\users\web\b406\ez.nancyholston\_fr\admin\menu_members.php on line 1 I've tried this as well include $_SERVER['DOCUMENT_ROOT']."/components\Header.php" But I get the same error. I've always programmed in ASP. I read that Windows servers base the path on the folder you are in, whereas Linux will base it on the root. Anyway, I'm sure there is a simple fix. Thanks Link to comment https://forums.phpfreaks.com/topic/194379-include-trouble/ Share on other sites More sharing options...
trq Posted March 6, 2010 Share Posted March 6, 2010 Backslashes have special meaning within double quotes and need to be escaped. <?php include "\\\\boswinfs01\\home\\users\\web\\b406\\ez.nancyholston\\components\\Header.php" ?> Link to comment https://forums.phpfreaks.com/topic/194379-include-trouble/#findComment-1022509 Share on other sites More sharing options...
TapeGun007 Posted March 6, 2010 Author Share Posted March 6, 2010 I cut and pasted your exact line, I get this error: Warning: main(\\boswinfs01\home\users\web\b406\ez.nancyholston\components\Header.php) [function.main]: failed to open stream: No such file or directory in \\boswinfs01\home\users\web\b406\ez.nancyholston\_fr\admin\menu_members.php on line 1 Warning: main() [function.include]: Failed opening '\\boswinfs01\home\users\web\b406\ez.nancyholston\components\Header.php' for inclusion (include_path='.;c:\php\4\pear') in \\boswinfs01\home\users\web\b406\ez.nancyholston\_fr\admin\menu_members.php on line 1 Members Menu: Again, the include file is here: \\boswinfs01\home\users\web\b406\ez.nancyholston\components\Header.php The file calling the include is here: \\boswinfs01\home\users\web\b406\ez.nancyholston\admin\menu.php Link to comment https://forums.phpfreaks.com/topic/194379-include-trouble/#findComment-1022512 Share on other sites More sharing options...
Zane Posted March 6, 2010 Share Posted March 6, 2010 just a shot in the dark, but I think you only need this if not this Link to comment https://forums.phpfreaks.com/topic/194379-include-trouble/#findComment-1022513 Share on other sites More sharing options...
TapeGun007 Posted March 7, 2010 Author Share Posted March 7, 2010 I've already tried both of those, I get this with BOTH: Warning: main(\components\Header.php) [function.main]: failed to open stream: No such file or directory in \\boswinfs01\home\users\web\b406\ez.nancyholston\_fr\admin\menu_members.php on line 1 Warning: main() [function.include]: Failed opening '\components\Header.php' for inclusion (include_path='.;c:\php\4\pear') in \\boswinfs01\home\users\web\b406\ez.nancyholston\_fr\admin\menu_members.php on line 1 Link to comment https://forums.phpfreaks.com/topic/194379-include-trouble/#findComment-1022515 Share on other sites More sharing options...
kgrayjr Posted March 7, 2010 Share Posted March 7, 2010 when this happens to me, I usually have forgotten something in the path. This is the main reason I use $_SERVER['DOCUMENT_ROOT'] when I cannot use relative paths. include ($_SERVER['DOCUMENT_ROOT'] . '/phpTest/components/Header.php'); Of course change the phpTest to the correct folder. Oh, just as a test run open a php file with this in it: echo $_SERVER['DOCUMENT_ROOT']; It will insure that everything is as expected (and not changed through the server ini file). Link to comment https://forums.phpfreaks.com/topic/194379-include-trouble/#findComment-1022530 Share on other sites More sharing options...
TapeGun007 Posted March 7, 2010 Author Share Posted March 7, 2010 Ok, the echo $_SERVER['DOCUMENT_ROOT']; give me this: \\\\boswinfs01\\home\\users\\web\\b406\\ez.nancyholston I tried all these: <?php include ($_SERVER['DOCUMENT_ROOT'] . '\\components\\Header.php'); ?> <?php include ($_SERVER['DOCUMENT_ROOT'] . '\components\Header.php'); ?> <?php include ($_SERVER['DOCUMENT_ROOT'] . '/components/Header.php'); ?> I get this error: Warning: main(\\\\boswinfs01\\home\\users\\web\\b406\\ez.nancyholston\components\Header.php) [function.main]: failed to open stream: No such file or directory in \\boswinfs01\home\users\web\b406\ez.nancyholston\_fr\admin\menu_members.php on line 1 Warning: main() [function.include]: Failed opening '\\\\boswinfs01\\home\\users\\web\\b406\\ez.nancyholston\components\Header.php' for inclusion (include_path='.;c:\php\4\pear') in \\boswinfs01\home\users\web\b406\ez.nancyholston\_fr\admin\menu_members.php on line 1 Link to comment https://forums.phpfreaks.com/topic/194379-include-trouble/#findComment-1022531 Share on other sites More sharing options...
TapeGun007 Posted March 7, 2010 Author Share Posted March 7, 2010 Oh man, it just dawned on me... and now I feel very stupid. It's a sub domain, and there was one additional folder that I left out of the string, because it doesn't exist in the URL. Even the first example basically works now, sorry guys, and thank you. Link to comment https://forums.phpfreaks.com/topic/194379-include-trouble/#findComment-1022533 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.