【问题标题】:Facing file get html error面对文件获取html错误
【发布时间】:2015-07-10 14:07:37
【问题描述】:

我在使用 cron 作业触发文件时遇到以下错误,而手动触发时它没有显示任何错误。请帮助这个错误背后的逻辑是什么。谢谢

致命错误:在 /home/afghannewscom/public_html/auto/MainProject.php35 中的非对象上调用成员函数 find()

【问题讨论】:

  • $OuterLink = file_get_html('khaama.com/'); $link = $OuterLink -> find('div[class=latest] ul li a');回声 $link = $link[0]->href; $filename = 'Latest.txt'; $link_in = file_get_contents($filename);
  • 请编辑您的原始帖子以在此处添加错误,而不是在 cmets 中。
  • 这里是错误:致命错误:在 /home/afghannewscom/public_html/auto/MainProject.php 第 35 行
  • 在第 35 行的 file_get_html() 中遇到问题

标签: php error-handling file-get-contents


【解决方案1】:

查看第 35 行的文件 MainProject.php(在编辑器中),看看有什么问题。
变量$OuterLink 不是对象。你可以看看它的定义行。

【讨论】:

  • 这是第 35 行:$OuterLink = file_get_html('khaama.com/');
  • 谁能告诉我为什么 file_get_url() 不能与 CRONE Jobs 一起工作,而手动触发时可以。
【解决方案2】:

cronjobs 也有类似的问题(仅 cronjobs 中的 PHP 错误,通过浏览器运行文件很好)。该错误是由不正确的服务器配置引起的(它是一个共享服务器,所以我无法更改它)。就我而言,修复非常简单——我将 cronjob 从“php -q /some_file.php”更改为“curl http://somedomain.com/some_file.php”(您也可以使用 lynx 或 wget 命令代替 curl)

【讨论】:

  • 我想它也对我有用,请告诉我这是什么意思? curl: (3) 格式错误我在邮件中收到了这个而不是错误
  • URL(文件名)有问题。那这个呢? "wget -O /dev/null yourdomain.com/some_file.php"
猜你喜欢
  • 1970-01-01
  • 2017-03-28
  • 1970-01-01
  • 2010-10-13
  • 1970-01-01
  • 1970-01-01
  • 2023-02-03
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多