PDA

View Full Version : PHP includes not working anymore


TurboGFX
12-06-2007, 10:29 AM
Hey there guys

I was just wondering if any of you out there have had the similar problem since BH has upgraded to apache2 and if so, what did you do to correct it.

On most of my pages on the domain, I have 2 php includes, but since the upgrade, they give me an error like this:

"Warning: main(http://www.domain.com/dir/file.php) [function.main]: failed to open stream: HTTP request failed! HTTP/1.1 500 Internal Server Error"

Any ideas what I can try to get them working again?

Any help would be greatly appreciated, as Im begining to pull my hair out

TurboGFX

redsox9
12-06-2007, 11:07 AM
I have not experienced this. How are you calling the includes?

TurboGFX
12-06-2007, 03:59 PM
Ive tried both ways I know of, they are as follows:

<?php include("../directory/file.php"); ?>

and

<?php include("http://www.domain.com/directory/file.php"); ?>

It ised to work with the first one, but no more

bobdog
12-06-2007, 05:04 PM
This works for me as well. No problems with Apache 2.2.6

Aha! Can't use the http path, and I suspect that your include using ../directory/file.php is the culprit

Try using <?php include("directory/myfile.php"); ?>

areidmtm
12-06-2007, 05:24 PM
With includes you have to use the servers path.


include($_SERVER['DOCUMENT_ROOT'] . '/directory/myfile.php');


$_SERVER['DOCUMENT_ROOT'] will give you /home/USERNAME/public_html. If you're using an add-on domain, that directory will be included at the end.

So your include will look like /home/USERNAME/public_html/directory/myfile.php

TurboGFX
12-06-2007, 05:33 PM
Woohooo...

areidmtm, you are a legend, I have just tried it out on a test page and it works perfectly.

Thanks a stack

redsox9
12-06-2007, 05:52 PM
Hmmm... interesting because I do use the HTTP path in most instances but perhaps I will make the change as suggested here by areidmtm (always the wealth of knowledge).

TurboGFX
12-06-2007, 06:05 PM
Seing that that is working,

I was wondering if I could put a command line in the .htaccess file instead of physically changing every page on the sites

redsox9
12-06-2007, 06:07 PM
Okay I tried that but it seems like if I have an include like this:

<?php include($_SERVER['DOCUMENT_ROOT']."/folder/file.php?var1=1"); ?>

the script won't run. It WILL run if I reference the HTTP path.

TurboGFX
12-06-2007, 06:17 PM
Well, Ill have to have a play around a bit in the morning... fun fun fun.

Thanks again to all of the help and advice on the matter, I greatly appreciate it.