echo file_get_contents working on some servers but not other

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
krox
Forum Newbie
Posts: 1
Joined: Wed May 26, 2010 7:36 am

echo file_get_contents working on some servers but not other

Post 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
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: echo file_get_contents working on some servers but not o

Post 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.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
phu
Forum Commoner
Posts: 61
Joined: Tue Mar 30, 2010 6:18 pm

Re: echo file_get_contents working on some servers but not o

Post by phu »

The easiest way to fix this would be to use the standard PHP cURL functions rather than depending on the file wrappers.
User avatar
phdatabase
Forum Commoner
Posts: 83
Joined: Fri May 28, 2010 10:02 am
Location: Fort Myers, FL

Re: echo file_get_contents working on some servers but not o

Post by phdatabase »

Have you checked PHP versions?
Post Reply