$select = " SELECT * FROM comments WHERE type=$row->title; ORDER BY id desc" .
" LIMIT $low, $PerPage";
$final = mysql_query($select) or die('Error!');
$行级别>标题;之前已创建,它具有类似Type1,Type2或其他值的值。当我启动该脚本时,结果是“错误!”。你能告诉我为什么吗?我已经尝试了很多方法来解决问题,但没有任何结果。这是其中之一:
$mytype=$row->title;
$select = " SELECT * FROM comments WHERE type=$mytype; ORDER BY id desc" .
" LIMIT $low, $PerPage";
$final = mysql_query($select) or die('Error!');
答案 0 :(得分:3)
删除;在$ row-title之后,即:
$select = " SELECT * FROM comments WHERE type='$row->title' ORDER BY id desc" . " LIMIT $low, $PerPage";
答案 1 :(得分:0)
你应该回应出mysql_error() - MySQL会告诉你出了什么问题!
dqhendricks和Cybernate的答案是正确的 - 你应该用单引号括起你的字符串。
然而 - 你也应该逃避你的文字,否则你最终会得到更多错误:
$select = "SELECT * FROM comments WHERE type='" . mysql_real_escape_string($row->title) . "' ORDER BY id desc LIMIT $low, $PerPage";