mariom Posted October 6, 2009 Share Posted October 6, 2009 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? Quote Link to comment https://forums.phpfreaks.com/topic/176636-file_get_contents-not-working/ Share on other sites More sharing options...
khr2003 Posted October 6, 2009 Share Posted October 6, 2009 see this topic: http://www.phpfreaks.com/forums/index.php?topic=204274.0 Quote Link to comment https://forums.phpfreaks.com/topic/176636-file_get_contents-not-working/#findComment-931241 Share on other sites More sharing options...
.josh Posted October 6, 2009 Share Posted October 6, 2009 show some code Quote Link to comment https://forums.phpfreaks.com/topic/176636-file_get_contents-not-working/#findComment-931242 Share on other sites More sharing options...
mariom Posted October 6, 2009 Author Share Posted October 6, 2009 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); Quote Link to comment https://forums.phpfreaks.com/topic/176636-file_get_contents-not-working/#findComment-931246 Share on other sites More sharing options...
redarrow Posted October 6, 2009 Share Posted October 6, 2009 What are you trying to do there mate? Quote Link to comment https://forums.phpfreaks.com/topic/176636-file_get_contents-not-working/#findComment-931319 Share on other sites More sharing options...
mariom Posted October 6, 2009 Author Share Posted October 6, 2009 What I'm trying to do is to send a couple variables to a page and it will respond. based on the response, i redirect to one of to pages. I get the "headers already sent" message aswell, but i think that it is related to the file_get_content warning. Quote Link to comment https://forums.phpfreaks.com/topic/176636-file_get_contents-not-working/#findComment-931410 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.