Error in login system using SQL Server. resource (7) of type (SQL Server Statement)

0

I'm trying to make a login system between PHP and SQL Server and is giving the resource (7) of type (SQL Server Statement) error.

index.php

<form class="form-horizontal" id="FormLogin" action="login.php" method="post">
   <div class="form-group">
      <label for="login">Login</label>
      <input type="text" class="form-control" id="login" name="login" placeholder="Entre com o seu Login">
   </div>
   <div class="form-group">
      <label for="senha">Senha</label>
      <input type="password" class="form-control" id="senha" name="senha" placeholder="Entre com a sua Senha">
   </div>
   <button type="reset" class="btn btn-default">Limpar</button>
   <button type="submit" class="btn btn-danger pull-right">Entrar</button>
</form>

login.php

<?php

include 'conexao.php';
include 'banco-usuario.php';

$usuario = buscaUsuario($conn, filter_input(INPUT_POST, 'login'), filter_input(INPUT_POST, 'senha'));
var_dump($usuario);

bank-user.php

$query = "select * from usuario where login = '{$login}' and senha = '{$senha}'";

//$resultado = mysqli_query($conn, $query); //MySQLi
$resultado = sqlsrv_query($conn, $query); //SQL Server


return $resultado;

}

I do not know what to do to resolve this. I want to make a system that uses login.

    
asked by anonymous 19.10.2016 / 19:45

1 answer

0

The message resource(7) of type (SQL Server Statement) is not an error, it is a text representation of the resource (which can be a query). Your query was processed with sqlsrv_query() but failed to extract result with sqlsrv_fetch_array() .

To correct add a return with the result already extracted:

$resultado = sqlsrv_query($conn, $query);
return sqlsrv_fetch_array($resultado, SQLSRV_FETCH_ASSOC);
    
19.10.2016 / 20:25