Search code examples
phpsyntax-errorparse-error

PHP T_STRING error when opening a file


So I have the following code:

$files = array("l01" => "l01.txt", "l02" => "l02.txt", "l03" => "l03.txt", "l04" => "l04.txt", "l05" => "l05.txt", "l06" => "l06.txt");

    $email = $_POST['email'];
    $lfile = $_POST["lab"];

    echo $email."</br>";
    echo $lfile."</br>";

    $f = fopen($files[$lfile],'a')
    fwrite($f, $email);

and I am getting the following error:

PHP Parse error:  syntax error, unexpected T_STRING in blah blah blah

the line number giving is the line for the fwrite, but I know the problem in in the fopen line. Can someone tell me how to fix this? I have tried everything I can think of and the best I acomplished was changing the error to a T_ECHO error.


Solution

  • You are missing a semicolon on the fopen line

    $f = fopen($files[$lfile],'a');