Page 1 of 1

Trouble with include function

Posted: Tue Dec 20, 2005 5:13 pm
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

Posted: Tue Dec 20, 2005 5:35 pm
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.

Posted: Tue Dec 20, 2005 6:17 pm
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;

Posted: Tue Dec 20, 2005 6:36 pm
by Buddha443556
Check to make sure "allow_url_fopen" is on?

Posted: Wed Dec 21, 2005 2:43 am
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?

Posted: Thu Dec 22, 2005 10:49 am
by Dr Evil
I have fiddled around with it and it certainly is a problem on the "included" server side