
January 18th, 2006, 04:04 PM
|
|
Contributing User
|
|
Join Date: Jan 2004
Location: Cincinnati, OH USA
Posts: 61
Time spent in forums: 9 h 8 m 35 sec
Reputation Power: 7
|
|
|
Fopen during loop
I am trying to open a webpage during a while loop and searching it for a specified link. Also, if fopen cannot open the page, how can I display an error besides the ugly php error? Also, what would be the best way to do this so it doesn't time out because there will be thousands of records pulled from this query. See my code below:
Thanks everyone in advance for any help you can provide. I've been working on this for hours!
PHP Code:
while ($row = mysql_fetch_array($sql)){
$sitetosearch_url = $row['sitetosearch'];
$mysite="http://www.linktosearch.com";
$site="http://$sitetosearch_url";
$fp = fopen ($site, "r");
if (!$fp){
}else{
while (!feof($fp)){
$contents.= fgets ($fp,128);}
fclose ($fp);
}
if(!strstr($contents,$mysite)){
echo ("no - $sitetosearch_url<br /><br />");
}else{
echo ("yes - $sitetosearch_url<br /><br />");
}
}
|