$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!');
最佳答案
删除;在 $row-title 之后,即:
$select = " SELECT * FROM comments WHERE type='$row->title' ORDER BY id desc" . " LIMIT $low, $PerPage";
关于mysql - 无法在 mysql Select 中使用变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4549624/