Web Hosting Talk







View Full Version : Why is this error coming up? PHP


mainarea
02-17-2004, 06:58 PM
$fp = fsockopen("ssl://".$host, $port, $errno, $errstr, $timeout = 30);

if(!$fp){
//error tell us
echo "$errstr ($errno)\n";

}else{

//send the server request
fputs($fp, "POST $path HTTP/1.1\r\n");
fputs($fp, "Host: $host\r\n");
fputs($fp, "Content-type: application/x-www-form-urlencoded\r\n");
fputs($fp, "Content-length: ".strlen($poststring)."\r\n");
fputs($fp, "Connection: close\r\n\r\n");
fputs($fp, $poststring . "\r\n\r\n");
//loop through the response from the server
while(!feof($fp)) {
echo fgets($fp, 4096);
}
//close fp - we are done with it

fclose($fp);


Parse error: parse error, unexpected $ in (file) on line 48

The line giving me the error is:

fclose($fp);

What's wrong there? It looks like it's correct according to http://www.php.net/manual/en/function.fclose.php .

- Matt

Rich2k
02-17-2004, 07:03 PM
You haven't closed your else {} statement for starters.

mainarea
02-17-2004, 07:58 PM
Heh... it's always the dumb things. Now I'm getting:

Warning: fclose(): supplied argument is not a valid File-Handle resource in (file) on line 45

Any thoughts?
$fp = fsockopen("ssl://".$host, $port, $errno, $errstr, $timeout = 30);

if(!$fp){
//error tell us
echo "$errstr ($errno)\n";
}
else{

//send the server request
fputs($fp, "POST $path HTTP/1.1\r\n");
fputs($fp, "Host: $host\r\n");
fputs($fp, "Content-type: application/x-www-form-urlencoded\r\n");
fputs($fp, "Content-length: ".strlen($poststring)."\r\n");
fputs($fp, "Connection: close\r\n\r\n");
fputs($fp, $poststring . "\r\n\r\n");
//loop through the response from the server
while(!feof($fp)) {
echo fgets($fp, 4096);
}
}
fclose($fp);


- Matt

mainarea
02-17-2004, 08:38 PM
I changed it from ssl to normal http, and now it works. Just need to figure out how to do something else with the script.

- Matt

Rich2k
02-18-2004, 05:32 AM
What version of PHP are you running as the ssl:// type was only added in version 4.3.0