pg.ddx.io pgsql-php@postgresql.org mailing list archive
help / color / mirror / Atom feedProblem with the type date
2+ messages / 2 participants
[nested] [flat]
* Problem with the type date
@ 2003-01-28 12:04 Jesus Rios <galiza-vermelha@wanadoo.es>, (by way of Jesus Rios <galiza-vermelha@wanadoo.es>
2003-01-28 12:43 ` Re: Problem with the type date Matthew Horoschun <mhoroschun@canprint.com.au>
0 siblings, 1 reply; 2+ messages in thread
From: Jesus Rios @ 2003-01-28 12:04 UTC (permalink / raw)
To: pgsql-php
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.
-------------------------------------------------------
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: Problem with the type date
2003-01-28 12:04 Problem with the type date Jesus Rios <galiza-vermelha@wanadoo.es>, (by way of Jesus Rios <galiza-vermelha@wanadoo.es>
@ 2003-01-28 12:43 ` Matthew Horoschun <mhoroschun@canprint.com.au>
0 siblings, 0 replies; 2+ messages in thread
From: Matthew Horoschun @ 2003-01-28 12:43 UTC (permalink / raw)
To: Jesus Rios <galiza-vermelha@wanadoo.es>; (by way of Jesus Rios <galiza-vermelha@wanadoo.es>; +Cc: pgsql-php
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
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2003-01-28 12:43 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2003-01-28 12:04 Problem with the type date Jesus Rios <galiza-vermelha@wanadoo.es>, (by way of Jesus Rios <galiza-vermelha@wanadoo.es>
2003-01-28 12:43 ` Matthew Horoschun <mhoroschun@canprint.com.au>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox