p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


  Return to Index  

beginning_php thread: open a remote file with fopen (PHP3)


Message #1 by "Andrew Walker" <catbert303@y...> on Thu, 27 Feb 2003 00:07:47
Hi,

I've been working on a small program to gather links from pages and save 
them in a database (for some data analysis later) unfortunatly i'm having 
to use PHP3 (booo! ;)).

i've been using the following function to read the pages,

function readPage($page) {
    $content = '';
    if (!$fp = fopen($page, 'r')) {
        return 'fail';
    }
    while (!feof($fp)) {
        $content .= fread($fp, 1000);
    }
    return $content;
}

for the most part this has been working fine, until today I noticed an 
error message coming from fopen when it was trying to read pages that 
contained google search results for example the page,

http://www.google.com/search?hl=en&ie=UTF-8&oe=UTF-8&q=PHP

the error message is,

Warning: fopen("http://www.google.com/search?hl=en&ie=UTF-8&oe=UTF-
8&q=PHP","r") - Error 0 

any idea why google search would be different to other sites tested? for 
example the google directory seems okay, as do search results from all the 
web etc...

take care,
Andy
Message #2 by "Andrew Walker" <catbert303@y...> on Thu, 27 Feb 2003 11:59:08
Hi,

I think i've worked out how to get round the problem. I can read the page 
if I use fsockopen - http://www.php.net/manual/en/function.fsockopen.php 
i'm still not quite sure why fopen was failing trying to read the page 
though...

Andy
Message #3 by "Nikolai Devereaux" <yomama@u...> on Thu, 27 Feb 2003 10:46:16 -0800
Perhaps the fopen for your PHP version didn't handle URLs with lots of GET
parameters in the query string, I dunno...


But why, why, why are you using PHP3???

Message #4 by =?iso-8859-1?q?Andrew=20Walker?= <catbert303@y...> on Thu, 27 Feb 2003 23:20:41 +0000 (GMT)
It's not my fault, honest ;) 
i've been told they've tried on a couple of occasions
to install it, but they can't get it to work with the
version of solaris they have (it's not exactly a new
machine)

 --- Nikolai Devereaux <yomama@u...> wrote: > 
> Perhaps the fopen for your PHP version didn't handle
> URLs with lots of GET
> parameters in the query string, I dunno...
> 
> 
> But why, why, why are you using PHP3???
> 
> 

=====
flash help - http://www.flashkit.com/board/forumdisplay.php?forumid=70

__________________________________________________
Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts
http://uk.my.yahoo.com

  Return to Index