I have a problem in running the cron job.
here are my code:
<?php
$doc = new DOMDocument();
$doc->load( 'http://www.all-news.in/feed' );
$items = $doc->getElementsByTagName( "item" );
mysql_connect('host','username','pass');
mysql_select_db('dbname');
$i=0;
foreach( $items as $itemname )
{
// Here Business logic for Inserting the data
}
echo $i.' Imported';
?>
When I run this file in browser, it works fine, but when the cron executed I have got the below error:
<br />
<b>Warning</b>: DOMDocument::load(http://www.all-news.in/feed) [<a href='domdocument.load'>domdocument.load</a>]: failed to open stream: Connection timed out in <b>/home/content/98/7509598/html/amz/social-bookmark.in/cron_jobs/all_news.php</b> on line <b>4</b><br />
<br />
<b>Warning</b>: DOMDocument::load() [<a href='domdocument.load'>domdocument.load</a>]: I/O warning : failed to load external entity "http://www.all-news.in/feed" in <b>/home/content/98/7509598/html/amz/social-bookmark.in/cron_jobs/all_news.php</b> on line <b>4</b><br />
0 Imported
I tried your code out and I’m not getting any errors. I modified it a bit to give me some more feedback:
This gives me:
If you’re testing on a local environment (your laptop perhaps) then try restarting your web server. Other than that I’m not sure what’s wrong sorry.