homepage Welcome to WebmasterWorld Guest from 54.196.62.132
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
($ SERVER['DOCUMENT ROOT'] stopped working
gmac6791




msg:4664541
 12:49 pm on Apr 20, 2014 (gmt 0)

Not sure if this is a PHP issue or Apache, but I suspect the latter. My apologies if this is posted in the wrong place.

I have subdomains set up in my local dev environment, and I've been using the following code for a website while I work on it locally:

<?php
include($_SERVER['DOCUMENT_ROOT'] . "/includes/header.php");
?>


It worked flawlessly for weeks, but then I stopped work on it for about a month. Last night I went back to work on it, and it's broken. I am now getting this:

Warning: include(C:/web/Apache/htdocs/includes/header.php): failed to open stream: No such file or directory in C:\web\Apache\htdocs\sitename\index.php on line 6

Warning: include(): Failed opening 'C:/web/Apache/htdocs/includes/header.php' for inclusion (include_path='.;C:\php\pear') in C:\web\Apache\htdocs\sitename\index.php on line 6


Notice how 'sitename' (the root) appears in the second part of each warning but not the first. :-/

'Line 6' that's mentioned in the warning is simply
include($_SERVER['DOCUMENT_ROOT'] . "/includes/header.php");


The key factor here is that I have not changed a single thing about the project since I last worked on it. So I'm stumped as to why it is suddenly happening.

Restarted Apache, no go.
Rebooted computer, nothing.
Double checked code, still nothing.

I have an exact copy of the site on the remote server for testing with the host's server, and the code is exactly the same, but works as expected. So the problem is definitely local.

My suspicions are leaning towards any of the Windows updates that occurred during the month away from working on the project.

Does anyone have an idea of what might cause this sort of thing out the blue?

 

lucy24




msg:4664566
 5:50 pm on Apr 20, 2014 (gmt 0)

Does anyone have an idea

Yes, I do: It's the same gremlin that's been afflicting my MAMP installation for the last few days. I realize this is not a very helpful answer.

Warning: include(C:/web/Apache/htdocs/includes/header.php): failed to open stream: No such file or directory in C:\web\Apache\htdocs\sitename\index.php on line 6

Was this a direct cut-and-paste? Seems like there ought to be a /sitename/ on both sides of the path.

<begin grasping-at-straws mode>
Does anything behave differently if you replace the php line with SSI syntax?
</end gsm>

aristotle




msg:4664570
 6:04 pm on Apr 20, 2014 (gmt 0)

Well the message says "No such file or directory", so that might be a matter to thoroughly investigate, unless of course you've already done so. This type of thing happens to just about everybody at one time or another, and the solution is often very simple once you realize it.

gmac6791




msg:4664573
 6:22 pm on Apr 20, 2014 (gmt 0)

@lucy24: Yup, direct copy/paste. I have no idea why there's no /sitename/ on both sides.

I'll try SSI and see what happens.

@aristotle: Right, but the directory and file are there, where they have been all along. As mentioned, I made absolutely no changes to anything during my month away from it. And I double checked everything anyway, but see no reason it should be breaking.

Also, as mentioned, the entire project is mirrored on a remote server, and it works no problem.

aristotle




msg:4664574
 6:22 pm on Apr 20, 2014 (gmt 0)

Well I didn't see Lucy's post until now, and wouldn't have posted at all if I had seen it. I need to start being more careful about posting without refreshing the screen to see if someone else has posted in the meantime.

gmac6791




msg:4664603
 12:18 am on Apr 21, 2014 (gmt 0)

Alrighty then, problem solved and I should be voted dunderhead of the year.

When I first went back to work on this project yesterday, I opened my browser, typed in 'localhost', which listed all my projects, and clicked through to the site, which of course was broken.
Tonight I suddenly realized that by going there that way, the site opens as http:// localhost/sitename/.

It's a subdomain. Should be http:// sitename.localhost/


drrrrrrrrrrrrrrrrrrrrrr..........

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved