Forum Moderators: coopster

Message Too Old, No Replies

what are these server errors about?

         

nevdev

6:38 pm on Jul 5, 2005 (gmt 0)

10+ Year Member



I'm having problems with php includes. Sorry if this is a common one but I can't search the site!

The problem is that sometimes when I try to load my php page which has a few php includes in it, I get a server error message saying things like:
"Warning: main(): HTTP request Failed! HTTP/1.1 404 Not Found in /home/httpd/vhosts/mysite.com/httpdocs/index.php on line 1"
...and similar errors.

Sometimes, however, I load the page and everything looks as it should do. I can't tell what determines whether I get the errors or whether I get the page as it should look - it seems random.

The includes I've written seem to be normal. They are of the format:
<?php include("http://www.mysite.com/includes/file.php");?>
...which I think is OK - anything wrong?

Strangely (and again, only sometimes), when I try refreshing the page I get a 404 error and this strange URL in my address bar:
[mysite.com...]
...though sometimes a refresh will show the page as it should look.

What's happening? Thanks in advance.

jatar_k

6:55 pm on Jul 5, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



it seems you are including using a url

have you tried just doing it via the file system?

instead of
<?php include("http://www.mysite.com/includes/file.php");?>

you could use
<?php include $_SERVER['DOCUMENT_ROOT'] . "/includes/file.php";?>

nevdev

7:26 pm on Jul 5, 2005 (gmt 0)

10+ Year Member



Well I changed all the includes to reference the files locally instead and it seems to be OK. It was an intermittent thing so maybe it'll come back, but I think you've hit the nail on the head. Thanks!