1
My code was working correctly on the localhost, but when I went up to my web page, the following error appeared:
Fatal error: Call to Undefined method mysqli_result::fetch_all() in
This is the source code:
function find($table = null, $id = null) {
$database = open_database();
$found = null;
if ($id) {
$sql = "SELECT * FROM " . $table . " WHERE Codigo = " . $id;
$result = $database->query($sql);
if ($result->num_rows > 0) {
$found = $result->fetch_assoc();
}
} else {
$sql = "SELECT * FROM " . $table . " WHERE Status = true";
$result = $database->query($sql);
if ($result->num_rows > 0) {
$found = $result->fetch_all(MYSQLI_ASSOC);
}
}
close_database($database);
return $found;
}
The error is in that line: $found = $result->fetch_all(MYSQLI_ASSOC);
This is the foreach that lists the data, maybe it helps to find the error:
<?php if ($funcionarios) : ?>
<?php foreach ($funcionarios as $funcionario) : ?>
<tr>
<td><?php echo $funcionario['NomeCompleto']; ?></td>
<td><?php echo $funcionario['Porcentagem']; ?></td>
<td class="actions text-right">
<a href="Detalhes.php?Codigo=<?php echo $funcionario['Codigo']; ?>" class="btn btn-sm btn-success"><i class="glyphicon glyphicon-eye-open"></i> Visualizar</a>
<a href="Editar.php?Codigo=<?php echo $funcionario['Codigo']; ?>" class="btn btn-sm btn-warning"><i class="glyphicon glyphicon-pencil"></i> Editar</a>
<a href="Excluir.php?Codigo=<?php echo $funcionario['Codigo']; ?>" class="btn btn-sm btn-danger"><i class="glyphicon glyphicon-trash"></i> Excluir</a>
</td>
</tr>
sees if the extension
msqli
is enabled in PHP where you hosted the site.– Leandro Lima
This function needs mysql client installed if you don’t have to change the
fetch_all()
forfetch()
and a while.– rray
@rray, you can help me mount the while?
– user31040