Message: array_push() expects parameter 1 to be array, null given

liangjamy 2011-07-29 03:59:41
if(count($br_code)>0){
$br_where = array();
foreach ($br_code as $code)
{
array_push($br_where, "asr_product_code LIKE '$code%'");
}
array_push($where,"(".implode(" OR ", $br_where).")");
}

array_push($where,"(".implode(" OR ", $br_where).")"); 这行提示
A PHP Error was encountered

Severity: Warning

Message: array_push() expects parameter 1 to be array, null given

Filename: controllers/csv.php

Line Number: 109
...全文
1079 4 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
binarie 2011-07-29
  • 打赏
  • 举报
回复 1
array_push是无法操作一个值为NULL的变量的,需要确保第一个参数是有效的数组。

如果你希望一开始数组是空的,那应该进行初始化 $where = array();

如果数组是经过查询而来,那应该检查SQL语句是否正确,很可能是查询失败。
liangjamy 2011-07-29
  • 打赏
  • 举报
回复
SELECT * FROM (
SELECT ".(implode(',',$field))."
FROM {$this->table} AS `a`
LEFT OUTER JOIN `taobao_shujubao` AS `b` ON `a`.`asr_product_seq`=`b`.`fk_reseller_product_seq`
".(count($where) > 0 ? ' WHERE '.implode(' AND ',$where) : '')."
{$this->order}
{$this->limit}
) AS a
GROUP BY asr_product_seq

该行的语句最后出来的是
/* [models] - 60 */ SELECT * FROM ( SELECT `b`.`taobao_shujubao_data`,`b`.`taobao_shujubao_insert_time`,`b`.`taobao_shujubao_update_time` FROM asr_product AS `a` LEFT OUTER JOIN `taobao_shujubao` AS `b` ON `a`.`asr_product_seq`=`b`.`fk_reseller_product_seq` ORDER BY ORDER BY asr_product_code ASC, asr_product_seq DESC LIMIT 0, 1 ) AS a GROUP BY asr_product_seq
//////////////////////////////////////////////////
A Database Error Occurred

Error Number: 1064

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ORDER BY asr_product_code ASC, asr_product_seq DESC LIMIT 0, 1 ) AS a ' at line 7
xuzuning 2011-07-29
  • 打赏
  • 举报
回复
他不是说的很清楚了吗? $where 不是一个数组
binarie 2011-07-29
  • 打赏
  • 举报
回复
这错误提示似曾相识。。貌似是CodeIgniter框架?


$where变量的处理请贴出来一起看看,这个提示的含义是$where变量没有被赋值过。

如果没有处理过$where,应该进行初始化 $where = array();

21,893

社区成员

发帖
与我相关
我的任务
社区描述
从PHP安装配置,PHP入门,PHP基础到PHP应用
社区管理员
  • 基础编程社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧