我正在尝试创建一个将用户输入并将其添加到.txt文件的网页。它应该像这个网页http://150.216.54.86:808/homework8/AirlineSurvey.html一样工作 为什么我收到"解析错误:语法错误,意外&#39 ;;'"在第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 . "\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>";
}
}
&GT;
答案 0 :(得分:1)
您错过了)
的近似括号flock($SurveyFile, LOCK_UN;
,这就是您收到解析错误的原因。
应该是这个flock($SurveyFile, LOCK_UN);