我的CodeIgniter应用程序有点问题。
代码适用于我的笔记本电脑上安装的apache,它也可以在我的在线服务器上运行,但不能在客户端的主机上运行......;)
错误信息:
Severity: Warning
Message: array_keys() expects parameter 1 to be array, boolean given
Filename: database/DB_active_rec.php
Line Number: 1113
A PHP Error was encountered
Severity: Warning
Message: sort() expects parameter 1 to be array, null given
Filename: database/DB_active_rec.php
Line Number: 1114
A PHP Error was encountered
Severity: Warning
Message: Invalid argument supplied for foreach()
Filename: database/DB_active_rec.php
Line Number: 1144
A Database Error Occurred
You must use the "set" method to update an entry.
看来问题是关于insert_batch& update_batch方法。
有什么想法吗?
代码非常简单,它适用于我运行它的3台服务器中的2台。两个功能:
public function insert_tabs($fb_user_id, $fanpages) {
$tabs = array();
foreach($fanpages as $fanpage) {
$entry['ta_user_fb_id'] = $fb_user_id;
$entry['ta_fanpage_id'] = $fanpage['fa_fanpage_id'];
$entry['ta_text'] = "Put your content here.";
$tabs[] = $entry;
}
return $this->db->insert_batch('tabs', $tabs);
}
和
function set_random_links($entries) {
$insert = array();
foreach($entries as $fanpage) {
$fanpage_id = $fanpage['fa_fanpage_id'];
$links = $this->get_random_links();
foreach($links as $link) {
$entry['lf_fb_fanpage_id'] = $fanpage_id;
$entry['lf_link_id'] = $link->li_id;
$insert[] = $entry;
}
}
return $this->db->insert_batch('linksonfanpages', $insert);
}
理论上一切都很好。
答案 0 :(得分:0)
交叉检查php版本,MySQL版本并检查是否所有文件都正确上传。
大多数情况下,由于版本不匹配而发生此错误。
答案 1 :(得分:0)
首先,此错误表示您的$ fanpages不是数组。
A PHP Error was encountered
Severity: Warning
Message: Invalid argument supplied for foreach()
Filename: database/DB_active_rec.php
Line Number: 1144
public function insert_tabs($fb_user_id, $fanpages) {
$tabs = array();
if(is_array($fanpages)) {
foreach($fanpages as $fanpage) {
$entry['ta_user_fb_id'] = $fb_user_id;
$entry['ta_fanpage_id'] = $fanpage['fa_fanpage_id'];
$entry['ta_text'] = "Put your content here.";
$tabs[] = $entry;
}
}
if(count($tabs)) return $this->db->insert_batch('tabs', $tabs);
return -1;
}
另外,我们可以看到$ fanpages的来源吗?因为如果来自那个似乎是整个问题。