Fsockopen error

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I am attempting to connect to a remote server using fsockopen to post data to a php file. Here is the error i get:

Warning: fsockopen(): php_network_getaddresses: getaddrinfo failed: Name or service not known (is your IPV6 configuration correct? If this error happens all the time, try reconfiguring PHP using -- disable-ipv6 option to configure) in /home/customerservice/docs/ admin_ahmed/test.php on line 37

Here is the code i am using:


$reply = http_post("https://www.safetrustprocessing.com";, 80, "/ xml_order_processing.php", array("myXml" => $xml));
function http_post ($server, $port, $url, $vars) {
    $user_agent = "Mozilla/4.0 (compatible; MSIE 5.5; Windows 98)";
    $urlencoded = "";
    while (list($key,$value) = each($vars))
        $urlencoded.= urlencode($key) . "=" . urlencode($value) . "&";
    $urlencoded = substr($urlencoded,0,-1);

    $content_length = strlen($urlencoded);

    $headers = "POST $url HTTP/1.1
Accept: */*
Accept-Language: en-au
Content-Type: application/x-www-form-urlencoded
User-Agent: $user_agent
Host: $server
Connection: Keep-Alive
Cache-Control: no-cache
Content-Length: $content_length
";

    $fp = fsockopen($server, $port, $errno, $errstr);
    if (!$fp) {
        return false;
    }

    fputs($fp, $headers);
    fputs($fp, $urlencoded);

    $ret = "";
    while (!feof($fp))
        $ret.= fgets($fp, 1024);

    fclose($fp);

    return $ret;
}


Any ideas on the problem?

Robert

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux