I've got a script that opens an HTTP connection to another page and reads whats there. That all works fine, but if the page returns a 302 error (redirect) I need the script to call the new page. My script recursively calls itself with the new page to open, but fsockopen() doesn't connect.
<code>
$fp = fsockopen($url["host"], 80, $err_num, $err_msg);
if ($fp) {
fputs($fp, $header.$request);
while (!feof($fp)) {
$response .= fgets($fp, 4096);
}
fputs($fp, "Connection: close\r\n\r\n");
fclose($fp);
}
</code>
fsockopen() doesn't populate the $err_num or $err_mgs. The manual states that this is because of a problem before the connect() call.
Has anyone run into this or know how I should go about debugging it?