0
Hello, I’m trying to call a direct image of a folder created dynamically with php but the code returns me this error:
Recoverable fatal error: Object of class mysqli_result could not be converted to string in C: xampp htdocs Control panel products.php on line 103
here is the code used:
<?php
session_start();
include 'conn_prod.php';
include 'processa_img.php';
$tema = mysqli_query($conn_prod,"SELECT * FROM necessaires;");
$sql_query = mysqli_query($conn_prod, "SELECT * FROM necessaires WHERE tema");
while ($line = mysqli_fetch_array($sql_query)) {
# code...
$tema = $line['imagem'];
$nome_image = $lina['tema'];
};
?>
body of the document
More PHP
<div class="log_prods">
<div class="corpo_log">
<?php
//RECEBER O NUMERO DA PAGINA
$pagina_atual = filter_input(INPUT_GET, 'pagina');
$pagina = (!empty($pagina_atual)) ? $pagina_atual : 1;
//SETAR A QUANTIDADE DE ITENS POR PAGINA
$quant_result_pg = 5;
//CALCULAR O INICIO DA VISUALIZAÇÃO
$inicio = ($quant_result_pg * $pagina) - $quant_result_pg;
$pegar_result = "SELECT * FROM necessaires LIMIT $inicio, $quant_result_pg";
$result_produtos = mysqli_query($conn_prod, $pegar_result);
while ($row_produto = mysqli_fetch_assoc($result_produtos)) {
# code...
echo "<section><span>Tema :</span>" . $row_produto['tema'] . "<br>
<span>ID :</span>" . $row_produto['id_nec'] . "<div class='cont_img-prod'><img src='upload/$tema/$nome_image'></div></section><hr>";
};
?>
<?php
// PAGINAÇÃO - SOMAR A QUANTIDADE DE USUARIOS
$result_pg = "SELECT COUNT(id) AS num_result FROM necessaires";
$resultado_pg = mysqli_query($conn_prod, $result_pg);
$row_pg = mysqli_fetch_assoc($resultado_pg);
//echo $row_pg['num_result'];
//QUANTIDADE DE PAGINAS
$quantidade_pg = ceil($row_pg['num_result'] / $quant_result_pg);
?>
</div>
<div class="cont_setas"><div class="setas_">
<?php
//LIMITAR OS LINKS ANTES E DEPOIS
$max_links = 1;
echo "<a href='produtos.php?pagina=1'><i class='pag_pri fas fa-angle-double-left'></i></a>";
for ($pag_ant = $pagina - $max_links; $pag_ant <= $pagina - 1; $pag_ant ++) {
# code...
if ($pag_ant >= 1){
echo "<a href='produtos.php?pagina=$pag_ant'>$pag_ant</a>";
}
}
echo "$pagina";
for($pag_dep = $pagina + 1; $pag_dep <= $pagina + $max_links; $pag_dep ++){
if ($pag_dep <= $quantidade_pg) {
# code...
echo "<a href='produtos.php?pagina=$pag_dep'>$pag_dep</a>";
}
}
echo "<a href='produtos.php?pagina=$quantidade_pg'><i class='pag_ult fas fa-angle-double-right'></i></a>";
?>
</div></div>
I appreciate the help but the code still has the same problem but now it’s on line 106
– Leonardo Jordano
Is the code complete? Which line 106 is it troubling? Could be an error in the SQL command
– X4vier
the line is this: "<img src = 'upload/$theme/$name_image'>" nothing wrong so I think it’s concatenation that this wrong
– Leonardo Jordano
In that first block of code you have $tema = mysqli_query($conn_prod,"SELECT * FROM Necessaires;"); and then you overwrite that variable. That can’t be it?
– X4vier
our was that same kkk Thank you very much
– Leonardo Jordano