Syntax error php [closed]

1

I downloaded a simple help desk system, but it is returning the following error after login:

 Parse error: syntax error, unexpected '}' in C:\wamp\www\helpdesk\login.php on line 48

login.php

<?
include "config.php";
$date = date("d/m/y");
$hora = date("H:i");

@session_start(); 

if (!mysql_connect($Host, $Usuario, $Senha)) {
    echo mysql_error();
    exit();
}
mysql_select_db($Base);

$user = $HTTP_POST_VARS["username"];
$pwd  = $HTTP_POST_VARS["senha"];

$sQuery = "select cod_usuario, nom_usuario, login, pwd_usuario, nivel
           from   usuarios
           where  login = '" . $user . "'";
$oUser = mysql_query($sQuery)
         or die("Query invalida: " . mysql_error());

$row = mysql_fetch_object($oUser);
if ($num_rows = mysql_num_rows($oUser) == 1) {
    if ($row->pwd_usuario == $pwd) {
        if ($row->nivel == $Nivel) {
           $_SESSION["log_usuario"] = $user;
           $_SESSION["pwd_usuario"] = $pwd;
           $_SESSION["nom_usuario"] = $row->nom_usuario;
           $_SESSION["cod_usuario"] = $row->cod_usuario;

           $sQuery1 = "insert into acesso (cod_user, nome_user, data, hora)
             values ('" . $row->cod_usuario . "',
                     '" . $user . "',
                     '" . $date . "',
                     '" . $hora  . "')";
           mysql_query($sQuery1);
           echo "<script>window.location='index_2.php'</script>";
        } else {
               ?>
               <script language="JavaScript">
               <!--
               alert("Nivel acesso incorreto!");
               window.location = '"index.php';
               //-->
               </script>
            <?php
            } //linha do erro
    } else {
        ?>
            <script language="JavaScript">
            <!--
            alert("Senha incorreta!");
            window.location = 'index.php';
            //-->
            </script>
        <?php
    }
} else {
    ?>
        <script language="JavaScript">
        <!--
        alert("Usuário não encontrado!");
        window.location = 'index.php';
        //-->
        </script>
    <?php
}
?>
    
asked by anonymous 16.02.2016 / 12:34

1 answer

6

Obsolete PHP code, but answering your question.

At the beginning of the code you have <? change by <?php .

This is because all of its remaining openings are using <?php .

Try it, put everything <?php . Using both in the same code will give the error, which can lead to some misconceptions.

Your problem, though it seems, is not about missing braces.

This is enough to give the error Parse error: syntax error, unexpected '}'

See your "config.php" file if you do not have the same problem, as you are doing an include, the error can be inherited.

If you have access to the server settings, check your php.ini , search for the short_open_tag line, and change to "on". Restart the apache service.

After the above configuration, there will be no problem using short tags.

    
16.02.2016 / 13:03