注意:未初始化的字符串偏移量:2

时间:2016-02-12 00:56:56

标签: php

function forums($name, $id){
$forums = "";
$sql = mysql_query("SELECT * FROM ".prefix."FORUM WHERE FORUM_ID = '$id' ") or die(mysql_error());
if(mysql_num_rows($sql)>0){
    $rs = mysql_fetch_array($sql);
    $forums = Array(
        $rs[CAT_ID], $rs[F_STATUS], $rs[F_SUBJECT]
        );
}
if ($name == "CAT_ID"){$nom = 0;}
if ($name == "STATUS"){$nom = 1;}
if ($name == "SUBJECT"){$nom = 2;}


return($forums[$nom]);
mysql_free_result($sql);

}

我收到此错误:

  

注意:未初始化的字符串偏移量:在第1589行的C:\ xampp \ htdocs \ cp_inc \ function.php中为2

1 个答案:

答案 0 :(得分:0)

报价在哪里?

$rs[CAT_ID], $rs[F_STATUS], $rs[F_SUBJECT]

尝试放置一个:

$rs['CAT_ID'], $rs['F_STATUS'], $rs['F_SUBJECT']