Page 1 of 1
Include Files
Posted: Tue Jul 14, 2009 3:47 pm
by aliciadg
I am moving to a new server and I'm having issues with some include files. The files reside in my root web in a folder called includes (they are header and footer files). The files have the extension .inc. After to moving to the new server these work fine for locally stored files but when I call these include files from another server I get the following error:
Warning: include(
http://freemanweb11.freeman.tulane.edu/ ... header.inc) [function.include]: failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in C:\web\webdocs\wp-content\themes\freeman\header.php on line 39
Warning: include() [function.include]: Failed opening '
http://freemanweb11.freeman.tulane.edu/ ... header.inc' for inclusion (include_path='.;C:\php5\pear') in C:\web\webdocs\wp-content\themes\freeman\header.php on line 39
In php.ini both allow_url_fopen and allow_url_includes are set to "on". The is the same set up as on the old server where everything works fine. Oddly enough if I name the include files with an extension of .php they work fine. Can anyone point me in the right direction? My brain is wracked! Thanks in advance for any assistance.
Alicia
ETA: Another oddity, the error references c:\php5\pear. This folder does not exist when I check the phpinfo the configuration file loaded for all servers is what I expect it to be. When I installed php I installed in a folder on the root of c called "php" there is no php5 folder. I can't determine where this is coming from.
Re: Include Files
Posted: Tue Jul 14, 2009 7:25 pm
by Skara
aliciadg wrote:...but when I call these include files from another server I get the following error:
Warning: include(
http://freemanweb11.freeman.tulane.edu/ ... header.inc) [function.include]: failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in C:\web\webdocs\wp-content\themes\freeman\header.php on line 39
Warning: include() [function.include]: Failed opening '
http://freemanweb11.freeman.tulane.edu/ ... header.inc' for inclusion (include_path='.;C:\php5\pear') in C:\web\webdocs\wp-content\themes\freeman\header.php on line 39
...Maybe this is too obvious, but have you tried loading
http://freemanweb11.freeman.tulane.edu/ ... header.inc in a web browser? If you can't get it there, you won't get it through include() either.
Re: Include Files
Posted: Tue Jul 14, 2009 7:42 pm
by aliciadg
Yes, I tried this and I get a 404. However in this same folder I have been able to access .html and .php files. It's almost as if I need to tell something somewhere how to respond to a .inc or a .include file type....
ETA: I have double checked permissions on this folder as well.
Re: Include Files
Posted: Tue Jul 14, 2009 7:53 pm
by requinix
Don't try to access your own files (on the same server or another) over HTTP like that. It's silly. It means more bandwidth, more costs, slower loading time...
If you like those includes and want to use them then copy the files over to your server and include them from there.
Re: Include Files
Posted: Tue Jul 14, 2009 8:13 pm
by Skara
@aliciadg: including a url is the equivalent of loading it in a browser and grabbing the contents.
@tasairis: Correct.

There's always a possibility there's a good reason to include from another server, though.
Re: Include Files
Posted: Wed Jul 15, 2009 9:21 am
by aliciadg
tasairis wrote:Don't try to access your own files (on the same server or another) over HTTP like that. It's silly. It means more bandwidth, more costs, slower loading time...
If you like those includes and want to use them then copy the files over to your server and include them from there.
It's not really all that silly in my current environment, and is necessary in order for my users to properly maintain the site. I am dealing with over 25 users and over 50,000 files on 4 servers. Please address my issue of the include files if you have any helpful info.
Re: Include Files
Posted: Wed Jul 15, 2009 9:23 am
by aliciadg
Skara wrote:@aliciadg: including a url is the equivalent of loading it in a browser and grabbing the contents.
@tasairis: Correct.

There's always a possibility there's a good reason to include from another server, though.
Understood, does anyone have any input on why this might be happening?
Re: Include Files
Posted: Wed Jul 15, 2009 3:33 pm
by Skara
As I've stated before, the reason lies not in your code but in this server not being online:
http://freemanweb11.freeman.tulane.edu/
Re: Include Files
Posted: Wed Jul 15, 2009 3:44 pm
by aliciadg
It is online, it is not visible to those outside of the domain, but the server and the other server calling the include files are both online inside the same domain. My apologies for not being clear on that. As I stated before in my original post if I change the file extension from .inc to .php and I call the .php file as the include file it works.
Re: Include Files
Posted: Wed Jul 15, 2009 3:46 pm
by Skara
It is online, it is not visible to those outside of the domain
AH, sorry.. ^^;
if I change the file extension from .inc to .php and I call the .php file as the include file it works
... ^ do that.

Or change it to .inc.php if you like. Is .inc configured in your webserver(s) to parse as a php file?
Re: Include Files
Posted: Wed Jul 15, 2009 4:10 pm
by aliciadg
Okay, so I added it to the configuration and now it's working. It is so odd, though, the .inc files were being called by files stored locally and they were working, this was only an issue when using the full url path from another server to call the .inc files....
Bahhhh! Anyway, thanks for talking me through this, it's very helpful sometimes to just discuss it! I was literally losing my mind!
Re: Include Files
Posted: Wed Jul 15, 2009 5:21 pm
by Skara
That is weird it would only break then. Anyway, glad you got it working.
Re: Include Files
Posted: Wed Jul 15, 2009 8:19 pm
by JAB Creations
A suggestion...since it's best to run a copy of a site locally (or over a network server if you're at work in example)I highly recommend having a path(ing) system. That way you can ensure your work will work with minimal effort...if you change something you would only have to point in one place or another.
Code: Select all
<?php
if ($_SERVER['HTTP_HOST'] == "www.mydomain.com") {$truedbuser = "mycom";}
else if ($_SERVER['HTTP_HOST'] == "www.mydomain.net") {$truedbuser = "mynet";}
else if ($_SERVER['HTTP_HOST'] == "localhost") {$truedbuser = "jab";}
?>
...I do the same thing with my site's XHTML base element...
Code: Select all
<?php
echo '<base href="'.$cms->base1.$cms->base2.'" />' . "\n";
?>
...and in the $cms class I do pretty much the same thing as in my first chunk of code above to determine where everything should be located.
I also recommend looking at WHAT the current path is set versus where it's trying to include...
dir_1/dir_2/dir_3/dir_a/dir_b/
dir_1/dir_2/dir_3/dir_c/dir_d/
...find the difference and work from that.
