PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesPHP Development
The ASP Free website provides in-depth information on the latest developer tools available from Microsoft. Our cadre of writers, highly experienced industry experts, reveals the best ways to use established technologies as well as new and emerging technologies. Our coverage of Microsoft's development and administration technologies is among the most respected in the IT industry today.

ASP Free and Iron Speed Designer are giving away $5,500+ in FREE licenses. Iron Speed's RAD CASE toolset can save up to 80% of your coding time. One free license per week, one perpetual license per month!
Download and Activate to enter!

Intel® Graphics Performance Analyzers is a powerful tool suite for analyzing and optimizing your games, media, and graphics-intensive applications. Used by some of the best developers on the planet, Intel GPA lets you maximize your app’s performance.


Tutorials
| Forums

Download to Enter
| Contest Rules

DOWNLOAD INTEL® GPA FOR FREE

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old January 18th, 2006, 04:04 PM
sseiter sseiter is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Location: Cincinnati, OH USA
Posts: 65 sseiter User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 9 h 49 m 46 sec
Reputation Power: 9
Send a message via AIM to sseiter Send a message via Yahoo to sseiter
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 />");
}


Reply With Quote
  #2  
Old January 18th, 2006, 04:14 PM
n.eby's Avatar
n.eby n.eby is offline
doesn't like link-rollover ads
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Sep 2003
Posts: 1,820 n.eby User rank is First Lieutenant (10000 - 20000 Reputation Level)n.eby User rank is First Lieutenant (10000 - 20000 Reputation Level)n.eby User rank is First Lieutenant (10000 - 20000 Reputation Level)n.eby User rank is First Lieutenant (10000 - 20000 Reputation Level)n.eby User rank is First Lieutenant (10000 - 20000 Reputation Level)n.eby User rank is First Lieutenant (10000 - 20000 Reputation Level)n.eby User rank is First Lieutenant (10000 - 20000 Reputation Level)n.eby User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 1 Week 5 Days 5 h 32 m 42 sec
Reputation Power: 148
Use Curl instead of file functions. Curl is designed specifically to retrieve web pages, the file handling functions are not. Note you'll need the curl library enabled in your PHP instance, but usually that is not difficult.
http://www.php.net/curl

You'll get better handling of timeouts and errors. You also won't be subject to the potential disabling of URL fopen wrappers. (fopen()'s ability to open URLs as files is subject to a config setting in PHP)

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPHP Development > Fopen during loop


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.

© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 11 - Follow our Sitemap