PHP includes fail, but inconsistently

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
slade27
Forum Newbie
Posts: 21
Joined: Tue Apr 24, 2007 3:49 am

PHP includes fail, but inconsistently

Post by slade27 »

I have an index.html page that uses two php includes (I've made the appropriate addition to my .htaccess file to allow this to happen).

So far, so good. The index.html page loads fine along with the appropriate data from the includes -- for the first few times, at least. But if I refresh the index.html page several times on any given browser, one or both of the includes eventually returns an error message as follows:

Code: Select all

main(http://www.somedomain.com/articles/last10blurbs.php) [function.main]: failed to open stream: HTTP request failed! HTTP/1.1 403 Forbidden  in /home/somedirectory/public_html/index.html
Then, if I refresh the index.html page AGAIN, the includes both load correctly. And so on as I repeatedly refresh the page: Sometimes the includes load correctly, sometimes one or both of them load incorrectly.

I'm a newbie; however, this seems to me to be a permissions problem -- however, the permissions for index.html are set to 6-4-4, which I thought was correct.

My question is: Why do the includes sometimes fail and sometimes work, and how can I correct the problem?


Thanks.

Brian
Mohit_Prog
Forum Commoner
Posts: 26
Joined: Mon Apr 23, 2007 6:10 am

Post by Mohit_Prog »

include never fails.
In which way [s]u[/s] you have included? can [s]u plz[/s] you please write those statements here.
mentor
Forum Contributor
Posts: 100
Joined: Sun Mar 11, 2007 11:10 am
Location: Pakistan

Post by mentor »

You should include in this way

Code: Select all

include "articles/last10blurbs.php";
not like

Code: Select all

include "http://www.somedomain.com/articles/last10blurbs.php";
slade27
Forum Newbie
Posts: 21
Joined: Tue Apr 24, 2007 3:49 am

Post by slade27 »

Sounds like you've diagnosed the problem.

Here's the sort of include statement I've been using:

Code: Select all

include 'http://www.somedomain.com/articles/showall.php';

Now I'll try:

Code: Select all

include "articles/showall.php";
Thanks.

Brian
Post Reply