Please, don't help me by showing me the code to fix it - but could you please explain 'why' I am getting this error? I realize it has something to do with me running out of links on the page but can you hint me towards the resolution without doing it for me? feof is what the problem is, but I'm sure that I can break the loop with break; but I can't seem to figure out how to get it to realize "Hey, I think that I should stop!".
/* Requirements To Run The Page */
require('./mysql.php');
require('./functions.php');
/* The First Searched Page */
$urlpage = 'http://blogsearch.google.com/blogsearch?hl=en&q=blah&btnG=Search+Blogs';
/* The amount of times that the process will be looped */
$times = 15;
/* The amount of times that links will be skipped */
$iteration = 11;
/* Start the loop */
for ($x = 0; $x < $times; $x++) {
$url = nth_link($urlpage, $iteration+=3);
$link2 = $url;
echo($link2);
echo('<hr><br>');
/* Let's pay a visit to the page */
$pagedata = "";
$filetext = fopen("$link2", "r");
/* Look at the whole page and get ALL the source from it */
while (!feof($filetext))
{
$theline = fgets($filetext, 2048);
$pagedata .= "$theline";
}
fclose($filetext);
/* Let's do some filtering so we dont get all that HTML junk - CSS too */
$pagedata = ereg_replace("<head>(.*)head>", "", $pagedata);
$pagedata = ereg_replace("<script>(.*)script>", "", $pagedata);
$pagedata = strip_tags($pagedata);
$pagedata = ereg_replace("'", "", $pagedata);
$pagedata = trim($pagedata);
mysql_query("INSERT INTO blog_data (blog_text) VALUES ('$pagedata')")
or die (mysql_error());
}
The error is:
Warning: feof(): 6 is not a valid stream resource in /home/sites/svcsports.net/public_html/blogged/index.php on line 49
... then the # is nine, then twelve (That's due to the count increasing by three.)