$tag = 6;
$user_checkn = db_query("SELECT ".$tag." FROM advent_user_check WHERE uid=".$_SESSION ['uid']." LIMIT 1");
$user_check = mysql_fetch_array($user_checkn);
echo $user_check[$tag];
这输出 6 而不是 0 的 db 值。为什么?
更新
想通了:列名周围的反引号丢失了:
$user_checkn = db_query("SELECT `".$tag."` FROM advent_user_check WHERE uid=".$_SESSION ['uid']." LIMIT 1");