Re: error Undefined index:

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Mar 28, 2018 at 12:04 AM, Romero, Fernando <
Fernando.Romero@xxxxxxxxxxxxxxxxxxxxxxx> wrote:

> 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
>
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
> what is the output of ?

var_dump( $_POST );​




-- 
<https://about.me/jigar?promo=email_sig&utm_source=product&utm_medium=email_sig&utm_campaign=edit_panel&utm_content=thumb>
Jigar Dhulla
about.me/jigar
<https://about.me/jigar?promo=email_sig&utm_source=product&utm_medium=email_sig&utm_campaign=edit_panel&utm_content=thumb>

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux