-1
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);
}
我收到此錯誤:注意:未初始化字符串偏移量:2
Notice: Uninitialized string offset: 2 in C:\xampp\htdocs\cp_inc\function.php on line 1589
首先,不使用的mysql_query。使用mysqli_query,或者更好地使用PDO。其次,你介意告訴我們你的示例代碼的哪一行是1589 – BillK
使用print_r($ rs);和chk什麼rcu得到 – devpro
或者也許它的$ rs [CAT_ID]應該是$ rs [0] ['CAT_ID'] :) – devpro