MySQL ORDER BY语句和PHP变量

时间:2013-10-01 02:47:50

标签: php mysql sql

嗨,我心情不好,我无法理解,请帮助。

这是我的sql:

$query = " select SQL_CALC_FOUND_ROWS * from programme where 1=1    ".$_SESSION['subject_where']." ".$_SESSION['practice_where']." ".$_SESSION['key_stage_where']." ".$_SESSION['targeted_group_where']." ".$_SESSION['search_where']." " ORDER BY Rating DESC " ";`

我的MySQL选择工作正常,但我想按评分订购我的搜索结果。当我在变量之后插入ORDER BY Rating DESC时,我总是会收到以下错误:

Error message: Parse error: syntax error, unexpected T_STRING in /home4/kenobi/public_html/programmes.php on line 23

请帮助 - 我做错了什么?

1 个答案:

答案 0 :(得分:2)

$query = " select SQL_CALC_FOUND_ROWS * from programme where 1=1 ".$_SESSION['subject_where']." ".$_SESSION['practice_where']." ".$_SESSION['key_stage_where']." ".$_SESSION['targeted_group_where']." ".$_SESSION['search_where']." ORDER BY Rating DESC ";

你有那些额外的报价。除此之外...... 1 = 1啊?这仅仅是为了测试吗?