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

发布于 2024-10-18 21:06:53 字数 3111 浏览 1 评论 0原文

我不断收到此错误:解析错误:语法错误,第 67 行 /Users/skline/Sites/tiptap/Site/tiptap/survey_current.php 中出现意外的“}”

但是,我所有的括号都已关闭!我真的很困惑,提前谢谢。

<?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'];

    ?>

I keep geting this error: Parse error: syntax error, unexpected '}' in /Users/skline/Sites/tiptap/Site/tiptap/survey_current.php on line 67

However, all my brackets are closed! I am really confused, thanks in advance..

<?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'];

    ?>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

§对你不离不弃 2024-10-25 21:06:53
    return $current_survey

该行缺少分号。

    return $current_survey

Missing semicolon on this line.

染火枫林 2024-10-25 21:06:53

返回 $current_survey ->丢失的 ”;”?

return $current_survey -> missing ";"?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文