What is the reason for this error?, Warning: mysqli fetch array () expects parameter 1 to be mysqli result, boolean given in error error line [duplicate]

this question already has an answer here : mysqli_fetch_object () expects parameter 1 (1 answers) Closed 4 years ago .
<table class="table table-bordered">
            <thead>
              <tr>
                <th>Clave</th>
                <th>Nombre</th>
                <th>Apellidos</th>
                <th>Formación Académica</th>
                <th>Dirección</th>
                <th>Correo</th>
                <th>Teléfono</th>
                </tr>
            </thead>
         <tbody>
    <?php
      if ($row = mysqli_fetch_array($sqlDoc)) { //linea de error fetch array
    ?>
    <tr>
      <td><?php echo $row['clave'];?></td>
      <td><?php echo $row['nombre'];?></td>
      <td><?php echo $row['apellidos'];?></td>
      <td><?php echo $row['formacion'];?></td>
      <td><?php echo $row['direccion'];?></td>
      <td><?php echo $row['correo'];?></td>
      <td><?php echo $row['telefono'];?></td>

function buscaDocente($clave)
{
global $connect;
$sqlDoc = mysqli_query($connect, "SELECT * FROM profesores WHERE clave = ".$clave);
return $sqlDoc;
}
 0
Author: Armando Arellano, 2016-10-16

1 answers

You should try to print the value of mysqli_error() since it is returning a boolean for sure because you have an error in your query.

$sqlDoc = mysqli_query($connect, "SELECT * FROM profesores WHERE clave = ".$clave) or die(mysqli_error()); 
 1
Author: vusano, 2016-10-16 22:05:30