473,947 Members | 1,791 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

can't retrieve data from the net with file_get_conten ts ?!

Rob
for some reason i keep getting :

Warning: file_get_conten ts(): php_network_get addresses: getaddrinfo failed:
Temporary failure in name resolution in
/home/rob/www/php/filegetcontents 2.php on line 3

Warning:
file_get_conten ts(http://folding.stanford.edu/teamstats/team92.txt): failed
to open stream: Resource temporarily unavailable in
/home/rob/www/php/filegetcontents 2.php on line 3

when trying to retrieve a page of text (stats for a distributed computing
project) from the Net like this :

$personal =
file_get_conten ts("http://folding.stanfor d.edu/teamstats/team92.txt");

i also tried implode/file ... same error.
but when i fill in the URL in Mozilla it is retrieved just fine and no
'temporary failures' at all ?!

what could be going wrong with the name resolution ??
Jul 17 '05 #1
2 4223
Rob <un*****@anonym ous.net> wrote in message
news:<vu******* *****@corp.supe rnews.com>...

when trying to retrieve a page of text (stats for a distributed computing
project) from the Net like this :

$personal =
file_get_conten ts("http://folding.stanfor d.edu/teamstats/team92.txt");

i also tried implode/file ... same error.
but when i fill in the URL in Mozilla it is retrieved just fine and no
'temporary failures' at all ?!

what could be going wrong with the name resolution ??


Nothing. Most likely, it's not name resolution at all. Try this:

$host = 'folding.stanfo rd.edu';
$path = 'teamstats/team92.txt';
$fp = fsockopen ($host, '80');
if ($fp) {
fputs($fp, 'GET '.$path." HTTP/1.0\r\nHost: ".$host."\r\n") ;
} else {
die ('Oops... Nobody home...');
}
$data = '';
while (!feof ($fp)) {
$data .= fgets ($fp, 10240);
}
fclose ($fp);
echo '<pre>', $data, '</pre>';

Cheers,
NC
Jul 17 '05 #2
Rob
On 21 Dec 2003 00:11:23 -0800, (Nikolai Chuvakhin) wrote:
what could be going wrong with the name resolution ??
Nothing. Most likely, it's not name resolution at all.


then what could it be ??
the 'funny' thing is that when i run the code in PHP4.3.1 on Windows2000, it
works OK !!
but the same code in PHP4.3.3 in Linux (Mandrake 9.2) gives me the name
resolution errors ?!
Try this:

$host = 'folding.stanfo rd.edu';
$path = 'teamstats/team92.txt';
$fp = fsockopen ($host, '80');
if ($fp) {
fputs($fp, 'GET '.$path." HTTP/1.0\r\nHost: ".$host."\r\n") ;
} else {
die ('Oops... Nobody home...');
}
$data = '';
while (!feof ($fp)) {
$data .= fgets ($fp, 10240);
}
fclose ($fp);
echo '<pre>', $data, '</pre>';


Ok, i'll boot back into Linux later and try it !!

thanks !

--
Rob
Jul 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
12037
by: Alper Adatoz | last post by:
Hi, i have a little problem. i hope u guys give me a clear solution (: db: mssql i just want to put jpeg file to the image field at the mssql db. and after that i want to call it back..
0
1738
by: Chung Leong | last post by:
My contribution to the comp.lang.php FAQ: ------------------------------------------------------------- Q: How do I retrieve a page from a web site? A: Pass a URL to file() or file_get_contents(). The former returns the contents as an array of lines. The latter returns the same as string. Example: $html = file_get_contents("http://www.cnn.com");
5
11210
by: David Rasmussen | last post by:
Some sites seem to be session driven in the sense that if I visit the homepage and do a few clicks I can navigate anywhere I want, but if I paste the current location into a new browser window after having navigated to some page, it doesn't work. It just returns to the start page or says "timeout" etc. This means that I can't read these pages from PHP with $string = file_get_contents('http://some.url/blah/deep/link');
6
11676
by: Captain | last post by:
I'm looking to post data (GET) to a site using a php script - commands like fopen() file_content_gets won't retrieve the data. I assume this is because the server is expecting the request to come from a browser. What do I need to do to make sure the request appears to be coming form a browser, and what would be the best way of posting the data ? cURL pear fsockopen ? Do I need to recreate the headers that are sent via IE6 to spoof the...
5
23055
by: howa | last post by:
are there any advantage in replacing all fread() operations with file_get_contents() ? i.e. file_get_contents("/usr/local/something.txt") VS $filename = "/usr/local/something.txt";
6
8687
by: Justin | last post by:
Hi all, i need some help over here... i found the solution to export file from mysql db into *.csv. but is there anyway to convert the contents into *.doc and save in my webserver and providing a link for the end users to download the word file? FYI, the database records are obtained by end users submitting the forms themselve and i saved it in my db... Thanx.
3
3111
by: Severeon | last post by:
Ok, I am a newb to PHP, but I have a good backing in C++ and Java so I have been able to eek out what I need. I was going though a 'mambo' conversion of a web plug in for Smart launch, a cafe' administration program. Here is my code: $filename = 'data.dat'; $postvars = unserialize(file_get_contents($filename));
4
2755
by: Aetherweb | last post by:
This is probably really obvious, sorry, been a long day... I'm wanting to create a PHP file which is a template for an email, and read the file into a string, ready to send out using my email functions... but I want to be able to get the PHP file to be server processed so that its content is created on the fly. Eg in pseudo code, what I want to do is this: 1$email_param1 = "my email param 1";
9
21022
by: howa | last post by:
Target: To fetch a file using PHP and send to user Method 1: echo file_get_contents( $file_path ); Method 2: readfile( $file_path );
0
10162
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
11571
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10690
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
8254
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7429
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
6113
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
6331
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4945
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3541
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.