Jump to content

file_get_contents not working


mariom

Recommended Posts

hey guys, I have this script that posts data to another page and expects an output. I'm using file_get_contents and I get this message:

 

Warning: file_get_contents() [function.file-get-contents]: php_network_getaddresses: getaddrinfo failed: Name or service not known in /../../ on line 71

 

Warning: file_get_contents(http://../../) [function.file-get-contents]: failed to open stream: Success in /../../../ on line 71

 

could it be the server setting or version of php? but the page exists and works fine.

any ideas?

Link to comment
https://forums.phpfreaks.com/topic/176636-file_get_contents-not-working/
Share on other sites

here is the preceding code

 

$data=array('variable_1'=>$_REQUEST['x1'],'variable_2'=>$_REQUEST['x2']);
$data=http_build_query($data);
$context_options=array('http'=>array('method'=>'POST',
         'header'=>"Content-type: application/x-www-form-urlencoded\r\n".
         'Content-Length: '.strlen($data)."\r\n",
         'content'=>$data));
$context=stream_context_create($context_options);

$fp=file_get_contents('http://mysite.com/page.php', FALSE, $context);

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.