Uncaught Error: Call to undefined function mysql_query () [duplicate]

0

I'm doing my login system and giving the following error when signing in:

  

Fatal error: Uncaught Error: Call to undefined function mysql_query () thrown in D: \ xampp \ htdocs \ login.php on line 41

if (isset($_POST['entrar']) && $_POST['entrar'] == "login")
    {
    $usuario = $_POST['email'];
    $senha = $_POST['senha'];
    if (empty($usuario) || empty($senha))
        {
        echo "Prencha TODOS os campos";
        }
      else
        {
        $query = "SELECT nome, email, senha FROM usuarios WHERE email = '$email' AND senha = '$senha'";
        $result = mysql_query($query);
        $busca = mysql_num_rows($result);
        $linha = mysql_fetch_assoc($result);
        if ($busca > 0)
            {
            $_SESSION['nome'] = $linha['nome'];
            $_SESSION['email'] = $linha['email'];
            header('Location: index.php');
            exit;
            }
          else
            {
            echo "Login ou senha ligado";
            }
        }
    }
    
asked by anonymous 03.09.2017 / 00:44

1 answer

0

Do not use the function mysql , use mysqli .

We should not use "mysql" extension functions because their development has been discontinued; the extension is already deprecated , that is, code that uses these functions does not work.

For more details see: Why should not we use functions of type mysql_ *?

    
03.09.2017 / 01:11