Trouble with include function

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
User avatar
Dr Evil
Forum Contributor
Posts: 184
Joined: Wed Jan 14, 2004 9:56 am
Location: Switzerland

Trouble with include function

Post by Dr Evil »

I'm having problems with an include function.

Code: Select all

<?php
include ("http://service.rssvp.com/mason/rssvp/feed.html?id=424");
?>
or

Code: Select all

<?php
include ("http://service.rssvp.com/mason/rssvp/feed.php?id=424");
?>
the urls work fine but used in an include I get an error:
Warning: main(http://service.rssvp.com/mason/rssvp/feed.html?id=424): failed to open stream: HTTP request failed! HTTP/1.1 500 Internal Server Error in ...

See it here:
http://www.worldwatchreport.com/rss.php

I tried including other files with variables and had no trouble.

Any of you wizards know what the problem is? Thanks
Swede78
Forum Contributor
Posts: 198
Joined: Wed Mar 12, 2003 12:52 pm
Location: IL

Post by Swede78 »

If you're using PHP version prior to 4.3.0, a remote file won't work with include(). You may be better off using readfile() instead, depending on what you intend to do with the page you're inclduing.
User avatar
trukfixer
Forum Contributor
Posts: 174
Joined: Fri May 21, 2004 3:14 pm
Location: Miami, Florida, USA

Post by trukfixer »

actually you cant include the php code itself as a file - all you are going to get from a HTTP request is the output of the file.

if you want to include the output file into your PHP page, there's better ways than include()

you could use file_get_contents and then echo that out, for example..

Code: Select all

$include_this = file_get_contents('http://service.rssvp.com/mason/rssvp/feed.html?id=424');
echo $include_this;
User avatar
Buddha443556
Forum Regular
Posts: 873
Joined: Fri Mar 19, 2004 1:51 pm

Post by Buddha443556 »

Check to make sure "allow_url_fopen" is on?
User avatar
Dr Evil
Forum Contributor
Posts: 184
Joined: Wed Jan 14, 2004 9:56 am
Location: Switzerland

Post by Dr Evil »

I'm afraid none of the above solutions gave any results.

using

Code: Select all

<? ini_set('allow_url_fopen', 'on');?>
<?
$include_this = file_get_contents('http://service.rssvp.com/mason/rssvp/feed.html?id=424'); 
echo $include_this; 
?>
I get an error:
http://www.worldwatchreport.com/rss2.php

BUT I tried including this page

Code: Select all

<? include("http://forums.devnetwork.net/viewtopic.php?p=225299"); ?>
And it works OK:
http://www.worldwatchreport.com/rss3.php

Could it be a problem on the rssvp.com server side?
User avatar
Dr Evil
Forum Contributor
Posts: 184
Joined: Wed Jan 14, 2004 9:56 am
Location: Switzerland

Post by Dr Evil »

I have fiddled around with it and it certainly is a problem on the "included" server side
Post Reply