note 100965 rejected from function.fsockopen by danbrown
| From: | danbrown@php.net | Date: | Wed, 17 Nov 2010 18:44:56 +0000 |
| Subject: | note 100965 rejected from function.fsockopen by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-174130@lists.php.net to get a copy of this message | ||
Note Submitter: tomikh at email dot cz
----
Does anybody know why the function fsockopen causes this:
Warning: fsockopen() [function.fsockopen]: unable to connect to http://vyznam-jmen.wz.cz/vyhledavani.php:80
(Unable to find the socket transport "http" - did you forget to enable it when you
configured PHP?)
..I've used adjusted code from this discusion:
$host = 'vyznam-jmen.wz.cz/vyhledavani.php';
$service_uri = '/cgi-bin/processACT';
$vars = "action=send_datum&obdobi_do=17.11.&obdobi_od=17.11.";
# compose HTTP request header
$header = "Host: $host ";
$header .= "User-Agent: PHP Script ";
$header .= "Content-Type: application/x-www-form-urlencoded ";
$header .= "Content-Length: ".strlen($vars)." ";
$header .= "Connection: close ";
$fp = fsockopen("http://".$host, 80, $errno, $errstr);
// fopen("http://".$host, "r+");
if (!$fp)
{
echo "$errstr ($errno)<br/> ";
echo $fp;
}
else
{
fputs($fp, "POST $service_uri HTTP/1.1 ");
fputs($fp, $header.$vars);
fwrite($fp, $out);
while (!feof($fp))
{
echo fgets($fp, 128);
}
fclose($fp);
}