0

I have to find all the syntax errors in this php file, any help is appreciated

<?php
$WaitTime = addslashes($_POST['wait_time']);
$Friendliness = addslashes($_POST['friendliness']); //missing ) and ;
$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) //too many ))
    echo "<p>You must enter a value in each field. Click
     your browser's Back button to return to the form.</p>";   // no hr needed
else {
    $Entry .= $WaitTime . "\n";   //no .
    $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) //missing )
            fclose($SurveyFile);
    }   
        else
            echo "<p>The entry could not be saved!</p>";

}
?>

Edited by peter_budo: Formatting code

2
Contributors
1
Reply
2
Views
5 Years
Discussion Span
Last Post by Biiim
0

empty($Noise) //too many ))

Should be

empty($Noise)){ 

Cause it's inside an if statement, i added the curly bracket cause im not sure how it acts without them - i think it only will execute the next single line of code if you don't add a curly bracket

else {
//to
}else{//for the opened curly bracket on the if

$Entry = '';//$Entry is never defined?

flock($SurveyFile, LOCK_UN); //missing ) and missing ;

Heres what i ended up with anyway

<?php
$WaitTime = addslashes($_POST['wait_time']);
$Friendliness = addslashes($_POST['friendliness']); //missing ) and ;
$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)){ //too many ))
        echo "<p>You must enter a value in each field. Click your browser's Back button to return to the form.</p>"; // no hr needed
}else {
    $Entry = '';
    $Entry .= $WaitTime . "\n"; //no .
    $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); //missing )
            fclose($SurveyFile);
        }
    }else{
        echo "<p>The entry could not be saved!</p>";
    }
}
?>

Can't see anything else and all valid code according to zend studio now

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.