Problem with the type date

Problem with the type date

am 28.01.2003 13:04:52 von Jesus Rios

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:



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:


FECHA DE LA CONSULTA







(yyyy)


Thank you.

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

---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to majordomo@postgresql.org)

Re: Problem with the type date

am 28.01.2003 13:43:14 von Matthew Horoschun

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