douxie0824 2017-04-06 03:03
浏览 15
已采纳

PhP程序中的解析错误[重复]

This question already has an answer here:

I am trying to make a webpage that will take user input and add it to a .txt file. It is supposed to work like this webpage http://150.216.54.86:808/homework8/AirlineSurvey.html Why am I receiving "Parse error: syntax error, unexpected ';'" on line 27?

<?php
$WaitTime = addslashes($_POST["wait_time"]);
$Friendliness = addslashes($_POST["friendliness"]); //missing );
$Space = addslashes($_POST["space"]);
$Comfort = addslashes($_POST["comfort"]); //missing $
$Cleanliness = addslashes($_POST["cleanliness"]);
$Noise = addslashes($_POST["noise"]);
if (empty($WaitTime) ||
    empty($Friendliness) ||
    empty($Space) ||
    empty($Comfort) ||
    empty($Cleanliness) ||
    empty($Noise))
    echo "<hr /><p>You must enter a value in each field. Click
     your browser's Back button to return to the form.</p><hr />";
else {
        $Entry = $WaitTime . "
";
        $Entry .= $Friendliness . "
";
        $Entry .= $Space . "
";
        $Entry .= $Comfort . "
";
        $Entry .= $Cleanliness . "
";
        $Entry .= $Noise . "
";
        $SurveyFile = fopen("survey.txt", "w"); /missing ;
        if (flock($SurveyFile, LOCK_EX)) {
                if (fwrite($SurveyFile, $Entry) > 0) {
                        echo "<p>The entry has been successfully added.</p>";
                        flock($SurveyFile, LOCK_UN;
                        fclose($SurveyFile);
                else
                        echo "<p>The entry could not be saved!</p>";
            }
        } else
                echo "<p>The entry could not be saved!</p>";
    }
            empty($Noise))
    echo "<hr /><p>You must enter a value in each field. Click
     your browser's Back button to return to the form.</p><hr />";
else {
        $Entry = $WaitTime . "
";
        $Entry .= $Friendliness . "
";
        $Entry .= $Space . "
";
        $Entry .= $Comfort . "
";
        $Entry .= $Cleanliness . "
";
        $Entry .= $Noise . "
";
        $SurveyFile = fopen("survey.txt", "w"); //missing ;
//missing }
        }
        if (flock($SurveyFile, LOCK_EX)) {
                if (fwrite($SurveyFile, $Entry) > 0) {
                        echo "<p>The entry has been successfully added.</p>";
                        flock($SurveyFile, LOCK_UN;
                        fclose($SurveyFile);

                else
                        echo "<p>The entry could not be saved!</p>";
        }
        else {
                echo "<p>The entry could not be saved!</p>";
    }
}

?>

</div>
  • 写回答

1条回答 默认 最新

  • douyang2530 2017-04-06 03:27
    关注

    You've missed a close parenthesis ) at your flock($SurveyFile, LOCK_UN;, that's why you are receiving parse error.

    It should be like this flock($SurveyFile, LOCK_UN);

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料