【问题标题】:Email before download error php下载错误php之前的电子邮件
【发布时间】:2018-08-03 09:37:18
【问题描述】:

我在下载错误之前遇到了电子邮件问题

Warning: count(): Parameter must be an array or an object that implements Countable in /wp-content/plugins/email-before-download/includes/class-email-before-download-db.php on line 56

我该如何解决这个问题?

【问题讨论】:

  • php 中的函数 count 接受一个可数参数,如数组或对象。请看第 56 行,count 的参数可能是一个类似 count($param) 的字符串。您可以在 count 函数之前检查数组以防止错误
  • @MikeAron 看到这个public function item_exists($data) { //check if item exists and if it needs updated $query = $this->db->get_row("SELECT * FROM $this->item_table WHERE download_id = '" . $data['download_id'] . "'"); if (count($query) > 0) { if ($query->file != $data['file']) { $this->db->update($this->item_table, array('file' => $data['file']), array('id' => $query->id) ); } if ($query->title != $data['title']) { $this->db->update($this->item_table, array('title' => $data['title']), array('id' => $query->id) ); } return $query->id; } return false; } 我该如何解决这个问题?
  • 请将您的附加代码放在您的帖子中,而不是作为评论。
  • 你说这是一个WP插件。代码从头到尾都是错误的。数据库功能不是 WP 规范。所以我不能帮助你,我不知道 $this->db-get_row 会返回什么。但为了防止错误,您可以将 count($query) 替换为 is_array($query) && count($query)

标签: php wordpress email download


【解决方案1】:

为了防止错误。替换

 if (count($query) > 0) { 

 if (is_array($query) && count($query) > 0) { 

【讨论】:

  • 谢谢它的工作,但当我点击下载按钮时,填写联系表格7提交,但提交后没有下载链接
  • 正如我所说,我不知道它需要更深入分析的功能是什么。上面的代码只是为了防止错误。
猜你喜欢
  • 2012-02-05
  • 2016-06-30
  • 2012-06-22
  • 1970-01-01
  • 2016-07-20
  • 1970-01-01
  • 1970-01-01
  • 2012-03-08
  • 1970-01-01
相关资源
最近更新 更多