error Undefined index:
| From: | Romero, Fernando | Date: | Tue, 27 Mar 2018 18:34:07 +0000 |
| Subject: | error Undefined index: | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-326415@lists.php.net to get a copy of this message | ||
I have an error with a variable in $ _POST that I can not find how to solve it
This is the error
Notice: Undefined index: empresa in /var/www/jobs/ganancia_por_empresa_mes.php on line 34
This is the query
<?php
$empresa = $_POST['empresa'];
$mes = $_POST['meses'];
$anio = $_POST['anio'];
if ( $_POST ) {
$result=pg_query("SELECT empresa, sum(valor) valor FROM trabajos WHERE
empresa='$empresa' and to_char(fecha, 'TMMONTH')::varchar = '$mes' and
date_part('year', fecha)= '$anio'
group by empresa");
$registros= pg_num_rows($result);
}
?>
<div align="center">
<table border="1" cellpadding="1">
<tr>
<td><strong>Empresa</strong></td>
<td><strong>Total</strong></td>
</tr>
<?php
//mostrar resultados
for ($i=0;$i<$registros;$i++)
{
$row = pg_fetch_array ($result,$i );
//}
?>
<tr>
<td>
<?php
echo $row['empresa'];
?>
</td>
<td>$
<?php
echo $row['valor'];
}
?>
</td>
</tr>
</table>
</div>
<div align="center" ><a
href="ganancia_empresa_mes.php">Volver</a></div>
</body>
</html>
The error of line 34 is this:
$empresa = $_POST['empresa'];
Thanks