Warning: mysqli_query () expects parameter 1 to be mysqli, integer given

2

I have this code below:

<?php
$conecta_no_banco = require_once ('conecta_db.php');
$login = $_POST['login'];
$senha = $_POST['senha'];
$sql = mysqli_query($conecta_no_banco,"SELECT usuario FROM gerenciador_de_socios.autenticacao_usuarios") or die("Erro!");
$row = mysqli_num_rows($sql);
if(!$login || !$senha) {
    echo "Você deve digitar sua senha e login!";
    exit;
}

if ($row > 0) {
    echo "OK!";
}
mysqli_close($conecta_no_banco);
?>

When I run, it gives the error:

  

Warning: mysqli_query () expects parameter 1 to be mysqli, integer   given

What am I doing wrong?

    
asked by anonymous 25.05.2017 / 07:17

1 answer

3

In this code you have, remove the line:

$conecta_no_banco = require_once ('conecta_db.php');

and change to

require_once ('conecta_db.php');

and within the conecta_db.php file change your connection code to something like this:

$conecta_no_banco = mysqli_connect("127.0.0.1", "usuario", "senha", "banco");
    
25.05.2017 / 12:03