致命错误:不能在第 12 行的 C:\xampp\htdocs\includes\categories\categories.php 中使用字符串偏移作为数组
$categories[$parent][] = $row;
类别.php
<?php
$sql = "SELECT catid, catname, parentid FROM categories";
$res = mysql_query($sql);
while ($row = mysql_fetch_assoc($res)) {
$parent = intval($row['parentid']);
if (!isset($categories[$parent])) {
$categories[$parent] = array();
}
$categories[$parent][] = $row;
}
?>
<table border="0" cellpadding="10" cellspacing="0">
<tr>
<td valign="top">
<?php
$category_string = "";
function build_categories_options($parent, $categories, $level) {
global $category_string;
if (isset($categories[$parent]) && count($categories[$parent])) {
$level .= " - ";
foreach ($categories[$parent] as $category) {
$opt_value = substr($level.$category['catname'],3);
$category_string .= '<option value=""></option><option value="'.$category['catid'].'">'.$opt_value.'</option>';
build_categories_options($category['catid'], $categories, $level);
}
$level = substr($level, -3);
}
return $category_string;
}
$category_options = build_categories_options(0, $categories, '');
$category_options = '<select class="chosen" name="categories" id="categories">'.$category_options.'</select>';
echo $category_options;
?>
</td>
在我插入带有类别的帖子后,此错误将显示?