我在运行 cron 作业时遇到问题。
这是我的代码:
<?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';
?>
当我在浏览器中运行这个文件时,它工作正常,但是当我执行 cron 时出现以下错误:
<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