mysqli_query returns empty column

Asked

Viewed 44 times

0

I have a query that has the function of returning columns of 2 tables.

SELECT * FROM `Estoque` AS E JOIN `Produtos` AS P ON E.id_produto = P.id_produto

When this query is executed within phpmyadmin the result is satisfactory, follow the image.

inserir a descrição da imagem aqui

Well, passing to php I have the following function:

function montarEstoque($conexao)
{
    
    $sql = "SELECT * FROM `Estoque` AS E JOIN `Produtos` AS P ON E.id_produto = P.id_produto";
    
   $r = mysqli_query($conexao,$sql);
   
   $produtos = [];
   
   while($e = mysqli_fetch_assoc($r))
   {
       $produtos[] = $e;
   }
   
   return $produtos;
    
}

The function as expected works, recognizes the tables and columns to be captured, the array is mounted and absolutely no errors are mentioned (at least not in an obvious way)

My problem is that the spine aparencia (present in the image) comes with all blank results, and no data is recognized from the database, although the query is functional within phpmyadmin as already said

inserir a descrição da imagem aqui

Follow here 4 positions of the query return array showing the index aparencia is empty. (the standard follows for all 26 positions) and only this column shows this behavior.

[0] => Array ( [id_estoque] => 3 [id_produto] => 7 [loja] => [quantidade] => 20 [preco_dinheiro] => 320,00 [preco_cartao] => 340,00 [preco_custo] => [aparencia] => [abertura] => Direita Invertida [fornecedor] => Mugitec [categoria] => Porta [subcategoria] => Palheta [nome] => Porta Palheta 210x60 [medida] => 210x60 [observacoes] => ) 

[1] => Array ( [id_estoque] => 2 [id_produto] => 6 [loja] => [quantidade] => 5 [preco_dinheiro] => 200,00 [preco_cartao] => 220,00 [preco_custo] => [aparencia] => [abertura] => Selecione [fornecedor] => Esquadrivax [categoria] => Janela [subcategoria] => 4 Folhas [nome] => Janela 4 Folhas 100x150 [medida] => 100x150 [observacoes] => ) 

[2] => Array ( [id_estoque] => 4 [id_produto] => 8 [loja] => [quantidade] => 2 [preco_dinheiro] => 80,00 [preco_cartao] => 80,00 [preco_custo] => [aparencia] => [abertura] => [fornecedor] => Esquadrivax [categoria] => Lustre [subcategoria] => [nome] => Lustre 80 cm [medida] => 80 [observacoes] => ) 

[3] => Array ( [id_estoque] => 5 [id_produto] => 10 [loja] => [quantidade] => 20 [preco_dinheiro] => 180,00 [preco_cartao] => 200,00 [preco_custo] => [aparencia] => [abertura] => [fornecedor] => Mugitec [categoria] => Janela [subcategoria] => 2 Folhas [nome] => Janela 2 Folhas 100x150 [medida] => 100x150 [observacoes] => )

I believe the problem must be some error that went unnoticed in php, since the query has 100% of its functioning within phpmyadmin!

Thank you for your attention

  • Different situation, does this column have a special type? Have you tried to do the query by just returning it to see the result?

  • Its type is varchar, similar to other columns. When I do a query only of it the result is 100% satisfying kkk, everything comes right. And the funny thing is that when I try to add the values of this single column query in the query array mentioned in the question, the value is still empty believe? I may end up using two arrays to fill the html, would be a gambiarra that solves, but I really wanted to understand what is happening in this situation.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.