当所有括号都关闭时,与括号相关的PHP语法错误

时间:2011-02-22 22:09:08

标签: php syntax-error brackets

我一直收到此错误:Parse error: syntax error, unexpected '}' in /Users/skline/Sites/tiptap/Site/tiptap/survey_current.php on line 67

然而,我的所有括号都已关闭!我很困惑,提前谢谢..

<?php

    $dbc = mysql_connect(DATABASE_HOSTNAME,DATABASE_USERNAME, DATABASE_PASSWORD);
    if(!$dbc){
        die('Not connected' .mysql_error());
    }
    // Select database
    $db_selected = mysql_select_db(DATABASE_DATABASENAME, $dbc);
    // If fails, exit and cry
    if (!$db_selected) 
    {
        die ("can't connect : " .mysql_error());
    }

    function getCurrentSurvey($consumer_id){
        $last_survey_sql="SELECT DISTINCT ssr.SET_ID AS SET_ID,
                      ssr.SURVEY_ID AS SURVEY_ID
                      FROM branching_survey_responses AS bsr
                      JOIN survey_set_relation AS ssr
                      ON bsr.SET_ID=ssr.SET_ID
                      AND bsr.SET_ID=(SELECT Max(set_id)
                                    FROM branching_survey_responses
                                    WHERE CUSTOMER_ID=$consumer_id)
                      AND bsr.CUSTOMER_ID=$consumer_id;";

        $last_survey_result=mysql_query($last_survey_sql); 

        $last_set= mysql_result($last_survey_result,0,"SET_ID");

        $last_survey= mysql_result($last_survey_result,1,"SURVEY_ID");

        $last_question_sql="SELECT DISTINCT QUESTION_ID
                        FROM branching_survey_responses
                        WHERE QUESTION_ID=(SELECT Max(QUESTION_ID)
                                          FROM branching_survey_responses
                                          WHERE CUSTOMER_ID=$consumer_id
                                          AND SET_ID=$last_set)
                        AND CUSTOMER_ID=$consumer_id
                        AND SET_ID=$last_set;";

        $last_question_result=mysql_query($last_question_sql); 

        $last_question=mysql_result($last_question_result, 0, "QUESTION_ID");

        $survey_count_sql= "SELECT COUNT(*) AS survey_count
                        FROM surveytable;";

        $survey_count_result=mysql_query($survey_count_sql); 

        $survey_count=mysql_result($suvery_count_result, 0, "survey_count");

        $question_count_sql="SELECT Max(q.QUESTION_ID) AS question_count
                        FROM questions as q
                        JOIN branching_table as bt
                        ON bt.question_id=q.question_id
                        JOIN survey_set_relation as ssr
                        ON ssr.SET_ID=bt.SET_ID
                        AND ssr.SURVEY_ID=$last_survey;";

        $question_count_result=mysql_query($question_count_sql); 

        $question_count=mysql_result($question_count_result, 0, "question_count");

        $current_survey = array("last_survey"=>$last_survey, "last_question"=>$last_question, "survey_count"=>$survey_count, "last_survey"=>$question_count);

        return $current_survey

    }
    $test=getCurrentSurvey(217);

    echo $test['last_survey'];
    echo $test['last_question'];
    echo $test['survey_count'];
    echo $test['question_count'];

    ?>

2 个答案:

答案 0 :(得分:3)

返回$ current_survey - &gt;缺少“;”?

答案 1 :(得分:3)

    return $current_survey

在这一行上缺少分号。