943,619 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 2846
  • PHP RSS
Jun 2nd, 2005
0

fsockopen Jumping out of Loop

Expand Post »
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:


PHP Syntax (Toggle Plain Text)
  1.  
PHP Syntax (Toggle Plain Text)
  1.  
  2. $query_geturl = mysql_query("select * from sites");
  3. while($geturl = @mysql_fetch_array($query_geturl, MYSQL_ASSOC)) {


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


PHP Syntax (Toggle Plain Text)
  1.  
  2.  
  3. $fp = fsockopen ($url['host'], ($url['port'] > 0 ? $url['port'] : 80), $errno, $errstr, $timeout);
  4. if (!$fp) {
  5. $query_status = mysql_query("update sites set status = '2' where url = '$usersite'");
  6. }
  7. else {
  8. 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?
Similar Threads
Reputation Points: 13
Solved Threads: 0
Junior Poster in Training
cyberoptik is offline Offline
82 posts
since Apr 2004
Jun 4th, 2005
0

Re: fsockopen Jumping out of Loop

I assume your full code look like this below.
[PHP] $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...
}
}
[/PHP]

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

[PHP] $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...
}
}
[/PHP]
PoA
Reputation Points: 19
Solved Threads: 9
Posting Whiz in Training
PoA is offline Offline
234 posts
since Jul 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: Please Help: Unknown column
Next Thread in PHP Forum Timeline: CD Message Board





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC