我需要从我的数据库输出多行选择,如下所示。它输出第二行但不是第一行,并返回警告“警告:非法字符串偏移'char_name'”
$i = 0;
while($array = @mysql_fetch_assoc($query)){
$row[$i] = $array;
$char = $row[$i]['char_id'];
$$char['char_name'] = $row[$i]['char_name']; /warning is on this line
echo $char . " " . $$char['char_name'];$i++;
}
答案 0 :(得分:1)
你能否重建代码:
$i = 0;
while($array = @mysql_fetch_assoc($query)){
$row[$i] = $array;
$char = $row[$i]['char_id'];
$char_name = $row[$i]['char_name'];
echo $char . " " . $char_name;
$i++;
}
答案 1 :(得分:0)
将此更改为
$$char['char_name'] = $row[$i]['char_name']; /warning is on this line
echo $char . " " . $$char['char_name'];
$i++;
这个
$char['char_name'] = $row[$i]['char_name']; /warning is on this line
echo $char . " " . $char['char_name'];
$i++;