I'm using fsockopen to access site URL's stored in a database and retrieve the meta information from the site. The loop for getting the URL's looks like this:

 [font=Verdana, Lucida, Arial, Helvetica, sans-serif]$query_geturl = mysql_query("select * from sites");
while($geturl = @mysql_fetch_array($query_geturl, MYSQL_ASSOC)) {

Next is a bit of parsing code, and then this:

$fp = fsockopen ($url['host'], ($url['port'] > 0 ? $url['port'] : 80), $errno, $errstr, $timeout);
if (!$fp) {
$query_status = mysql_query("update sites set status = '2' where url = '$usersite'");
}
else {
blah blah blah...

The problem is, when fsockopen tries to access a site that is down or nonexistant, then it jumps out of the loop. I don't want it doing this. I want it to just update the database (setting status = 2 for the site) and then continue onto the next site. It doesn't even look like it's setting the status. It just exits out before the if statement.

How would I make fsockopen continue the loop? Or maybe an alternative to even using fsockopen?

Edited 3 Years Ago by pyTony: fixed formatting

I assume your full code look like this below.

$query_geturl = mysql_query("select * from sites");
while($geturl = @mysql_fetch_array($query_geturl, MYSQL_ASSOC)) {

$fp = fsockopen ($url['host'], ($url['port'] > 0 ? $url['port'] : 80), $errno, $errstr, $timeout);
if (!$fp) {
$query_status = mysql_query("update sites set status = '2' where url = '$usersite'");
}
else {
//blah blah blah...
}
}

Where does '$url' come from? '$url' means '$geturl'?
Also try like this below. Hope it helps.

$query_geturl = mysql_query("select * from sites");
while($geturl = @mysql_fetch_array($query_geturl, MYSQL_ASSOC)) {

$fp = fsockopen ($geturl['host'], ($geturl['port'] > 0 ? $geturl['port'] : 80), $errno, $errstr, $timeout);
if (!$fp) {
$query_status = mysql_query("update sites set status = '2' where url = '$usersite'");
}
else {
//blah blah blah...
}
}
This article has been dead for over six months. Start a new discussion instead.