Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

fsockopen fails in php script....?

Posted on 2003-11-11
4
Medium Priority
?
411 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
2 Comments
 
LVL 13

Accepted Solution

by:
lozloz earned 200 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses

782 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