Solved

fsockopen fails in php script....?

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Both Easy and Powerful How easy is PHP? http://lmgtfy.com?q=how+easy+is+php (http://lmgtfy.com?q=how+easy+is+php)  Very easy.  It has been described as "a programming language even my grandmother can use." How powerful is PHP?  http://en.wikiped…
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 …
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to count occurrences of each item in an array.

910 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now