Could not set variable with fetch_object

1

I'm trying to make a simple query however, although PHPMyAdmin perform the query, when I run the code Apache returns the message:

Notice: Undefined variable: rprd in D: \ xampp \ htdocs \ final \ views \ premorc.php on line 2723

My code looks like this:

$data   = date("d-m-Y");
$partes = explode("-", $data);
$ano    = $partes[2];
$lj    = $_GET['emp'];
$linha  = $_GET['ans'];
$modal  = $_GET['modal'];

$periodo = "$ano%";

$sql = "SELECT 
  sjy_vendas.tipo, 
  Sum(sjy_vendas.qt) AS qt, 
  Sum(sjy_vendas.qtv) AS qtv, 
  Sum(sjy_vendas.rprd) AS rprd, 
  Sum(sjy_vendas.rsrv) AS rsrv, 
  Sum(sjy_vendas.tprd) AS tprd, 
  Sum(sjy_vendas.tsrv) AS tsrv, 
  Sum(sjy_vendas.vlr_compra) AS vlr_compra
  FROM sjy_vendas
  WHERE sjy_vendas.empresa = $lj 
  AND sjy_vendas.tipo = $linha
  AND sjy_vendas.dt_nf LIKE '$periodo'
  GROUP BY sjy_vendas.tipo";

$resultado = $MySQLi->query($sql) OR trigger_error($MySQLi->error, E_USER_ERROR);
while ($dados = $resultado->fetch_object()) {


$qtv    = $dados["qtv"];
$rprd   = $dados["rprd"];
}

if($modal == "X"){
    $anterior = $qtv;
} else if($modal = "F"){
    $anterior = $rprd; // Essa é a linha 2723
}
    
asked by anonymous 19.10.2017 / 13:49

0 answers