Solved

fsockopen fails in php script....?

Posted on 2003-11-11
4
405 Views
Last Modified: 2008-03-03

I am calling an IIS XP server from a .php script located on a different server. When I try to open a post page from PHP, I get the following error:

Warning: fsockopen(): php_network_getaddresses: getaddrinfo failed: Name or service not known in /home/mylocal/test.php on line 9

The URL i am trying to open is an IP address of my IIS server using a cable modem. This may be a permissions problem but I cant identify if it is or not. I know that the IP for my IIS is correct, it's just that the php statement cant find it. Here is the code:

<?php
$host = 'http://111.222.333.444';
$port = 80;
$timeout = 10;
$uri = '/test.asp';
       
$postData = "product_name=product1";
$length = strlen($postData);
$socket = fsockopen($host, $port, $errno, $errstr, $timeout);
if(!$socket) {
         echo '$errstr ($errno)<br>\n';
}
else
{
  // do something
}

If anyone wants the actual addresses to help me, let me know. I will email it.
0
Comment
Question by:JavaDudeIL
4 Comments
 
LVL 13

Accepted Solution

by:
lozloz earned 50 total points
ID: 9725854
hi,

http://bugs.php.net/bug.php?id=11058

this page has some comments that you might want to read.. i can't suggest anything aside from this myself, other than changing the line $socket = fsockopen($host, $port, $errno, $errstr, $timeout); to $socket = @fsockopen($host, $port, $errno, $errstr, $timeout); since the error report might be more detailed echoing out the $errstr

cheers,

loz
0
 

Author Comment

by:JavaDudeIL
ID: 9741575
Thanks. I assume this may in fact be an IIS issue rather than PHP bug.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
This article discusses four methods for overlaying images in a container on a web page
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question