Solved

fsockopen fails in php script....?

Posted on 2003-11-11
4
404 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

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

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

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn how to dynamically set the form action using jQuery.
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 …

810 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