MaxMoon Posted June 13, 2007 Share Posted June 13, 2007 I'm trying to grab the contents of a .php page from a directory on my site and echo it on to my blog. I've done this successfully with .htm pages no problem, but .php seems to be giving me trouble. The code is simply this... <?php $emailpage = file_get_contents("http://www..com/signup/index.php"); echo $emailpage; ?> And I get this error: Warning: file_get_contents() [function.file-get-contents]: php_network_getaddresses: getaddrinfo failed: Name or service not known in /home/blog/public_html/signup/testing.php on line 3 Warning: file_get_contents(http://www..com/signup/index.php) [function.file-get-contents]: failed to open stream: Success in /home/blog/public_html/signup/testing.php on line 3 It seemed to be working fine, then I checked an hour later and it was no longer working. No changes made on my part. Can anyone help? Thanks, Stephen Link to comment https://forums.phpfreaks.com/topic/55365-file_get_contents-error/ Share on other sites More sharing options...
sKunKbad Posted June 13, 2007 Share Posted June 13, 2007 why not include() it? Link to comment https://forums.phpfreaks.com/topic/55365-file_get_contents-error/#findComment-273646 Share on other sites More sharing options...
MaxMoon Posted June 13, 2007 Author Share Posted June 13, 2007 I saw that function today, I'm only familiar with PHP enough to get in to trouble. Right now file_get_contents() seems to be working. I tried include() instead and it works, although it displays a "1" at the end of the content. Know how to get rid of that? Thanks, Stephen Link to comment https://forums.phpfreaks.com/topic/55365-file_get_contents-error/#findComment-273650 Share on other sites More sharing options...
trq Posted June 13, 2007 Share Posted June 13, 2007 Know how to get rid of that? Are you trying to echo the call to include? Don't do that. Link to comment https://forums.phpfreaks.com/topic/55365-file_get_contents-error/#findComment-273663 Share on other sites More sharing options...
MaxMoon Posted June 13, 2007 Author Share Posted June 13, 2007 I just changed it to this... <?php $emailpage = include("http://www..com/signup/index.php"); echo $emailpage; ?> But the code seems to work sometimes, and not work other times. So maybe my webhost? Stephen Link to comment https://forums.phpfreaks.com/topic/55365-file_get_contents-error/#findComment-273665 Share on other sites More sharing options...
trq Posted June 13, 2007 Share Posted June 13, 2007 You dont need to echo it. <?php include "http://www..com/signup/index.php"; ?> is sufficient. Link to comment https://forums.phpfreaks.com/topic/55365-file_get_contents-error/#findComment-273670 Share on other sites More sharing options...
neel_basu Posted June 13, 2007 Share Posted June 13, 2007 Your host doesnt allows you to use external Contents to stop Abuse and spam e.g. allow_url_fopen is turned Off. Link to comment https://forums.phpfreaks.com/topic/55365-file_get_contents-error/#findComment-273708 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.