PHP error, 'exit' (T_EXIT) [closed]

0

I'm practicing a bit of php, and when I run it, this error appears on the local host screen:

  

Parse error: syntax error, unexpected 'exit' (T_EXIT), expecting ','   or in C: \ xampp \ htdocs \ login.php on line 22

I understand what syntax error, however, I would like to understand the error.

[
<?php

$host = "localhost";
$user = "root";
$pass = "";
$db = "users";

mysql_connect($host, $user, $pass);
mysql_select_db($db);

if (isset($_POST['username'])) {
    $username = $_POST['username'];
    $password = $_POST['password'];

    $sql = "SELECT * FROM user WHERE username='".$username."'AND password='".$password."'LIMIT 1";
    $res = mysql_query($sql);
    if (mysql_num_rows($res) == 1) {
    echo "logado";
    exit();
    } else {
    echo "dados incorretos"
        exit();
    }
    }

?>
]
    
asked by anonymous 28.08.2014 / 15:49

1 answer

6

The error says that the function exit() was not expected but a ; ie the error is in the line before exit() .

} else {
   echo "dados incorretos" <---- cade o ponto e virgula ?
exit();

To avoid this kind of error use some IDE such as eclipse or editors text with advanced features like notepad ++ or sublimetext .

    
28.08.2014 / 15:59