-2

我有以下代码用于根据状态对表信息进行排序。

$query = "SELECT * FROM affiliate_tasks WHERE username = '$_SESSION[username]'";

if( isset($_POST['sort-selection'] && $_POST['sort-selection'] != 'all' ) ) 
{
   $query .= " AND status = '". $_POST['sort-selection']."';" ;
}

$result = mysqli_query($con, $query);

当我运行网页时,它给了我这个错误:

Parse error: syntax error, unexpected T_BOOLEAN_AND, expecting ',' or ')' in /home/content/38/10473938/html/website/panda/affiliates/task.php on line 60

第60行如下:

if( isset($_POST['sort-selection'] && $_POST['sort-selection'] != 'all' ) ) {

我无法弄清楚代码有什么问题,任何帮助将不胜感激!

4

2 回答 2

2

看起来好像您在该行的错误位置放置了右括号..

if( isset($_POST['sort-selection'] && $_POST['sort-selection'] != 'all' ) ) {

应该

if( isset($_POST['sort-selection']) && $_POST['sort-selection'] != 'all' ) {
于 2013-06-05T07:37:21.370 回答
0

右括号中有语法错误

if( isset($_POST['sort-selection']) && $_POST['sort-selection'] != 'all' ) 
                                //^this one was missed and added at the end
于 2013-06-05T07:38:32.940 回答