2017-04-06 62 views
-3

我正在嘗試製作一個網頁,它將接受用戶輸入並將其添加到.txt文件中。它應該像這個網頁http://150.216.54.86:808/homework8/AirlineSurvey.html 爲什麼我收到第27行「解析錯誤:語法錯誤,意外';'」?PhP程序中的解析錯誤

<?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 . "\n"; 
     $Entry .= $Friendliness . "\n"; 
     $Entry .= $Space . "\n"; 
     $Entry .= $Comfort . "\n"; 
     $Entry .= $Cleanliness . "\n"; 
     $Entry .= $Noise . "\n"; 
     $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 . "\n"; 
     $Entry .= $Friendliness . "\n"; 
     $Entry .= $Space . "\n"; 
     $Entry .= $Comfort . "\n"; 
     $Entry .= $Cleanliness . "\n"; 
     $Entry .= $Noise . "\n"; 
     $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>"; 
    } 
} 

?>

回答

1

你已經錯過了一個右括號)flock($SurveyFile, LOCK_UN;,這就是爲什麼您收到解析錯誤。

它應該是這樣的flock($SurveyFile, LOCK_UN);