如何删除“警告:不能将标量值用作数组”

时间:2011-07-06 13:44:49

标签: php

这是我的代码:

$i = 0;
$list4 = array();
while($row_sent = $GLOBALS['db']->sql_fetchrow($res_sent))
{   
    $sql_sent2 = "SELECT * FROM ".$GLOBALS['table']['sent']." WHERE `sent_id` ='".$row_sent['sent_id']."'";
    //echo $sql_size2; exit;
    $res_sent2 = $GLOBALS['db']->sql_query($sql_sent2);
    $num = $GLOBALS['db']->sql_numrows($res_sent2);
    if($num > 0)
    {
        while($row_sent2 = $GLOBALS['db']->sql_fetchrow($res_sent2))
        {
             $list4[$i]['sent_id']             = $row_sent2['sent_id']; //this line shows error
             $list4[$i]['sent_name']           = $row_sent2['sent_name'];//this line shows error
             $list4[$i]['sent_qty']            = $row_sent['sent_qty'];//this line shows error
        }
    }
    else
    {
      $list4=0;
    }
    $i++;
}

1 个答案:

答案 0 :(得分:0)

试试这个。

在循环开始之前将$list4声明为数组。

$list4[] = array();

这可能有用。

感谢。