Call to a member function rowCount () on boolean-Php

-2

Good friends, I am new here and I hope to ask this question well I'm trying to do a login based on roles, I have the roles in a separate table so I bring them using inner join in the query I just want you to enter by mail and password this is the code but when I log in I get this error "Call to a member function rowCount () on boolean" how can I correct it and thanks

<?php
  session_start();
    $correo=$_POST['correo'];
     $clave=md5($_POST['clave']);
      require_once('../php/cone.php');

      $query= "SELECT  id_usuario, nombre, apellido, correo, p.id_perfil, perfil FROM usuario u INNER JOIN perfil p ON p.id_perfil=u.id_perfil WHERE u.correo= $correo AND  u.clave= $clave"; 

      $resultado = $mysqli->query($query);



      if($resultado->rowCount()==1){
          $fila=$resultado->fetch();
          $_SESSION['idperfil']=$fila['id_perfil'];
         if($fila['id_perfil']==1)
         {
             header("Location: ../administrador/index.php");
         }
         if($fila['id_perfil']==2)
         {
             header("Location: ../aprendiz/index.php");
         }
         if($fila['id_perfil']==3)
         {  
             header("Location: ../root/index.php");
         }
      }
      else
      {
         echo "<font color='red'>Datos No Validos</font>";
      }

?>
    
asked by Furude 15.06.2018 в 10:23
source

1 answer

0

$resultado is returning FALSE because the query gives error.

The error is missing quotes in your query.

$query= "SELECT  id_usuario, nombre, apellido, correo, p.id_perfil, perfil FROM usuario u INNER JOIN perfil p ON p.id_perfil=u.id_perfil WHERE u.correo= '$correo' AND  u.clave= '$clave'"; 

Also rowCount does not exist. You have to use num_rows

$resultado->num_rows

Source num_rows

    
answered by 15.06.2018 в 10:31