2
I’m trying to make the page display the documents sent by the user, but always returns me the same error
Fatal error: Cannot use Object of type mysqli_result as array in >C: wamp64 www Project-School Student-Query.php on line 158
The code on the line is this
<h1>Documentos:</h1>
<?php $arrayDadosDocumentos = ObtemDocumentos($rg);
$idTipo = $arrayDadosDocumentos[2];?>
I have researched and always find the same solution, talking to use ``, but I do not know how to apply in my code.
At the moment that’s it, thank you for your attention.
p.s.: If you need any more information, please let me know.
Code of ObtemDocumento()
function ObtemDocumentos($rg){
include("conexao.php");
$SQL ="SELECT D.* FROM documento D JOIN alunodocumento AD WHERE AD.RG = ".$rg." AND D.IdCaixa = AD.IdCaixa AND D.IdLote = AD.IdLote AND D.idTipoDoc = AD.idTipoDoc ORDER BY D.idTipoDoc;" ;
$resultado = mysqli_query($conexao, $SQL);
if (!$resultado) {
$mensagem_erro = 'Erro de sintaxe na query: ' . mysqli_error() . "<br>";
$mensagem_erro .= 'SQL executado: ' . $SQL;
$destino = 'http://localhost/Projeto-escolweb/php/erro.php?msg='.$mensagem_erro;
header("Location: $destino");
exit;
}
return $resultado;
The problem is in
ObtemDocumentos()
probably missing the while with themysqli_fetch_assoc()
.– rray
could put the code of
ObtemDocumentos
?– novic
I edited the question, code is at the end of it.
– Victor Piovani
Guy the code I posted works perfectly in your case.
– Pedro Morais