Hi guys,
I'm trying to get "page contents from links" and insert that into database(auto process). I've tried the following way, but it doesn't seems to be working, I guess the file() function doesn't grab the contents on time when mysql is requesting it or something. I'm sure there are many other clean ways to do trick, but this is the way I've tried.. Please take a look at the code, you'll understand better what I'm saying..
problem: It gets the contents, but doesn't update the mysql row after that.. but it updates the field without the "grabbed website contents", please lend me a hand on this one. 🙂
TIA
<?php
//connect to db
//Mysql select the link and id from mylinks bla bla bla.. limit 0,1 to TEST..
//list the links
while($row = mysql_fetch_array($result))
{
list($ID, $Link) = $row;
//get the content
$count = file($Link);
$Contents = '';
foreach ($count as $line_num => $line)
{
$Contents = $Contents . $line;
}
$Contents = cleanHTML($Source);
}
//update a row with contetns
$query = mysql_query("UPDATE mylinks SET `pagecontents` = '$Contents' WHERE `id` = '$ID'");
echo 'Content Updated For ' . $Link . '<br>';
?>