Problem with the type date

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



Hi. I have written onces for the same question, with no sucess for me.
I have a table so:

  Table "s_objetivos_caso"
        Column      |  Type   | Modifiers
    -    ----------------+---------+-----------
 dni                    | integer | not null
 fecha                | date    | not null
 cod_s_objetivos | integer | not null


I have 3 variables in my form where i get the date:
$fecha_anho,$fecha_mes,$fecha_dia.
when i want to insert into the table io do so:


<?php

include ("globals.php");
$conn=conectarbd($user,$password,$dbname);
$tdate=$fecha_anho."-".$fecha_mes."-".$fecha_dia;-------> HERE IS THE PROBLEM

$tabla="s_objetivos_caso";
$dni=232;
$cod_s_objetivos=1;

$aux_s_obj=inserta_tabla_generica_caso($dni,$tdate,$cod_s_objetivos,$conn,$ta
bla); if(!$aux_s_obj)
         {
    	    echo ("Error al rellenar la tabla=s_objetivos_caso");
         }


?>
The function is :


 function inserta_tabla_generica_caso($denei,$data,$cod,$cone,$table)
  {
    $insert="INSERT INTO $table VALUES('$denei','$data','$cod')"; ********
    $result=pg_exec($cone,$insert);
    if ($result)
     {
     	return true;
     }
  else
     {
        return false;
     }
  }


The error  which throw me the navigator is:


Warning: PostgreSQL query failed: ERROR: Bad date external representation
'--' in /var/www/jesus/foniatra/globals.php on line 55
Error al rellenar la tabla=s_objetivos_caso

line 55 is which who has **********

In which format i must put the date for insert it into the table?

If it is a help , when i do:
foniatra=# SELECT  now()::date;   ------>
------------
 2003-01-28
(1 row)



In my form i have this:

 <tr>
                 <td  width="100%" align="center"> <b>FECHA DE LA CONSULTA
</b> </td>
                 <td  height="2">
                      <select name=fecha_dia  >
                        <option  selected value=1>01
                        <option value=2>02
                        <option value=3>03
                        <option value=4>04
                        <option value=5>05
                        <option value=6>06
                        <option value=7>07
                        <option value=8>08
                        <option value=9>09
                        <option value=10>10
                        <option value=11>11
                        <option value=12>12
                        <option value=13>13
                        <option value=14>14
                        <option value=15>15
                        <option value=16>16
                        <option value=17>17
                        <option value=18>18
                        <option value=19>19
                        <option value=20>20
                        <option value=21>21
                        <option value=22>22
                        <option value=23>23
                        <option value=24>24
                        <option value=25>25
                        <option value=26>26
                        <option value=27>27
                        <option value=28>28
                        <option value=29>29
                        <option value=30>30
                        <option value=31>31  </option>
                     </select>

                     <select name=fecha_mes>
                        <option selected value=1>enero
                        <option value=2>febrero
                        <option value=3>marzo
                        <option value=4>abril
                        <option value=5>mayo
                        <option value=6>junio
                        <option value=7>julio
                        <option value=8>agosto
                        <option value=9>septiembre
                        <option value=10>octubre
                        <option value=11>noviembre
                        <option value=12>diciembre </option>

                       </select>

                    <input maxlength=4 name=fecha_anho size=4>
                       (yyyy) </td>
              </tr>

Thank you.

-------------------------------------------------------


[Index of Archives]     [Postgresql General]     [Postgresql Admin]     [PHP Users]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Databases]     [Yosemite Backpacking]     [Postgresql Jobs]

  Powered by Linux