【发布时间】: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