Page 1 of 1

echo file_get_contents working on some servers but not other

Posted: Wed May 26, 2010 7:46 am
by krox
Hi there,

If anyone can help me, I would be REALLY grateful.

I am trying to pull the contents of another website on another server using the "echo file_get_contents('http://domain.com/index.php');" command. This works fine on some of my servers, but on others it does not get anything for 90% of my domains, but does on the other 10%. I have no idea why.

The page I am trying to load is:

Code: Select all


<?php
error_reporting(E_ALL ^ E_NOTICE);
echo file_get_contents('http://domain.com/tos/remote.php?id=3');
?>

But if I browse to the page I want to include (http://domain.com/tos/remote.php?id=3') that always loads fine, so the problem is not there.

thanks in advance for any advice

Keith

Re: echo file_get_contents working on some servers but not o

Posted: Wed May 26, 2010 11:16 am
by pickle
It's possible that some servers don't have http wrappers installed/configured/allowed for file functions. Unfortunately, I wasn't readily able to find how to determine that or how to fix it.

Re: echo file_get_contents working on some servers but not o

Posted: Wed May 26, 2010 7:27 pm
by phu
The easiest way to fix this would be to use the standard PHP cURL functions rather than depending on the file wrappers.

Re: echo file_get_contents working on some servers but not o

Posted: Fri May 28, 2010 10:46 am
by phdatabase
Have you checked PHP versions?