You already have the answer to your problem, but since no one has explained how the error should be read, here is my contribution so that in the future you can understand what PHP is saying:
Parse error: syntax error, Unexpected '{' in C: xampp htdocs exercicios saber2 php Session.php on line 4
The error is divided into 3 portions:
Type of error:
You got a Parse error
, family E_PARSE
which are basically mistakes that will prevent the execution from continuing.
Error:
You got syntax error
which indicates that something is wrong with the PHP code whose interpreter cannot understand.
Description:
The description of your error identifies the problem, the line and the file where the error is located.
In your case, unexpected '{'
on the line 4
of file C:\xampp\htdocs\exercicios\saber2\php\session.php
, that is, was found a {
on line 4 of said file, when something else was expected.
Once the error points to an unexpected character, the real problem is before it:
#01 <?php
#02
#03 session_start();
#04 if(isset($_SESSION['user']){
#05 echo "<script>document.location.href='../areaprivada.html';</script>";
#06 }
#07 else{
#08 echo "<script>document.location.href='login.php';</script>";*/
#09 }
#10 ?>
And so, on your #4 line, before the {
there should be something else. Analyzing from the beginning of the line to the {
we end up realizing that the parentheses of the if
with a )
.
More about the mistakes and their types:
remove the characters
*/
after the command ofelse
will probably fix the problem..– KaduAmaral