Jump to content

Include Trouble


TapeGun007

Recommended Posts

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
Share on other sites

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
Share on other sites

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
Share on other sites

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
Share on other sites

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.