PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesPHP Development

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: 61 sseiter User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 9 h 8 m 35 sec
Reputation Power: 7
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: 146
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




 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

 

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




© 2003-2010 by Developer Shed. All rights reserved. DS Cluster 6 Hosted by Hostway
For more Enterprise Application Development news, visit eWeek