"Notice: Undefined index:" error

-1

Hello!     I'm getting this message when trying to view the page.

Notice: Undefined index: IdInstaller in C: \ wamp64 \ www \ solus \ summary_dia.php on line 378

On line 378 I have the following structure.

375- $sqlEntregasRetornos_res = $conn->prepare($sqlEntregasRetornos);
376- $sqlEntregasRetornos_res->execute();        
377- $lstEntregasRet = $sqlEntregasRetornos_res>fetchAll(PDO::FETCH_ASSOC);
378- $teste = $lstEntregasRet["IdEntregador"];                      
379- var_dump($lstEntregasRet);

// Na linha 378 também tentei extrair da seguinte forma     
   $lstEntregasRet["IdEntregador"];
  

Displaying the contents of the variable is displaying the information correctly.   As below:

array (size=8)
  0 => 
    array (size=3)
      'IdEntregador' => string '4' (length=1)
      'QtdeRetorno' => string '4' (length=1)
      'Descricao' => string 'RETORNO' (length=7)
  1 => 
    array (size=3)
      'IdEntregador' => string '20' (length=2)
      'QtdeRetorno' => string '1' (length=1)
      'Descricao' => string 'RETORNO' (length=7)

The $ test variable returns null C: \ wamp64 \ www \ solus \ summary_dia.php: 381: null

I honestly do not know what I might be doing wrong, I have 4 other structures that are working perfectly, I checked all the information and I do not know what's wrong. I had another situation similar to this, but I solved it in 2 min, the problem was in the foreach structure, which is not the case now.

    
asked by anonymous 30.06.2018 / 23:28

1 answer

0

Your dump shows clearly what the problem is. Is that lstEntregasRet is receiving ALL rows from the query.

You have to do a foreach of lstEntregasRet and get every subarray,

foreach ($lstEntregasRet as $linha)
{
    $IdEntregador = $linha['IdEntregador'];
    ...
}
    
30.06.2018 / 23:34