Forum Moderators: coopster

Message Too Old, No Replies

problem reading remote page

opens the page over and over

         

sampford

11:45 am on Jul 29, 2005 (gmt 0)

10+ Year Member



hi guys,

i am having a some difficulty with the following code;

PHP Code:

$file = fopen ("$url", "r");
if (!$file) {
echo "<p>Unable to open remote file.\n";
exit;
}
while (!feof ($file)) {
$line = fgets ($file, 1024);
/* This only works if the title and its tags are on one line */
if (eregi ("<TITLE>(.*)</TITLE>", $line, $out)) {
$title = $out[1];
break;
}
}
fclose($file);

It is doing its job perfectly on one seve I have - but on a new host I have - it seems to be causing the page it is reading, to be opened and executed over and over again. Can anyone here think of a fix - that will allow it to just read the file once - without executing the file.

Basically - this is reading the title tags of a page, and feeding this into a counter - that requires the page title (this is what $title is). $url is grabbed from the current page that has been opened up in the browser. And from there - is supposed to be read (not executed) - where the title can be grabbed, and passed to the counter.

Any help would be great!

coopster

1:44 am on Aug 3, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld, sampford.

I'm not exactly certain what you mean by executed over and over again. Is there another loop wrapped around this process?