Problem with the type date

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_ob jetivos,$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
<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.

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

---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to majordomo [at] postgresql.org)
Jesus Rios [ Di, 28 Januar 2003 13:04 ] [ ID #31259 ]

Re: Problem with the type date

Hi There,

> Warning: PostgreSQL query failed: ERROR: Bad date external
> representation
> '--' in /var/www/jesus/foniatra/globals.php on line 55

Okay... so that means the variables $fecha_anho, $fecha_mes, and
$fecha_dia are empty.

I'm guessing here, but it might be because you're running a recent
version of PHP where register_globals has been turned off by default.

Try this:

$tdate =
$_REQUEST['fecha_anho']."-".$_REQUEST['fecha_mes']."-
".$_REQUEST['fecha_dia'];

Try echoing $tdate directly after this line to make sure its set
correctly.

Also, in your HTML, it is good practice to always quote parameter
values.

Matthew.

--
Matthew Horoschun
Network Administrator
CanPrint Communications Pty. Ltd.


--
Matthew Horoschun
Network Administrator
CanPrint Communications Pty. Ltd.

Mobile: 0417 282 378
Direct: (02) 6295 4544
Telephone: (02) 6295 4422
Facsimile: (02) 6295 4473


---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org
Matthew Horoschun [ Di, 28 Januar 2003 13:43 ] [ ID #31260 ]
Datenbanken » gmane.comp.db.postgresql.php » Problem with the type date

Vorheriges Thema: where must i put a Script to check if a form is ok??
Nächstes Thema: PROBLEMA CON EL TIPO DATE DE UNA COLUMNA DE UNA TABLA