Re: Inserting Dates into a postgresql database
| From: | Alexandru Coseru | Date: | Tue, 29 Apr 2003 09:27:37 +0000 |
| Subject: | Re: Inserting Dates into a postgresql database | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-145607@lists.php.net to get a copy of this message | ||
Try this:
$datetoday = "$year-$month-$day";
Alex
----- Original Message -----
From: "Matt MacLeod" <matt@bigbarn.co.uk>
To: <php-general@lists.php.net>
Sent: Tuesday, April 29, 2003 12:05 PM
Subject: [PHP] Inserting Dates into a postgresql database
> Hi,
>
> I'm having trouble formatting a date to be inserted into a postgresql
> date field.
>
> Basically I have a feedback form and I want to log the date
> (day/month/year) in the database as well as the feedback form fields.
>
> This is my current effort:
>
> -------->
> $today = getdate();
> $year = $today['year'];
> $month = $today['month'];
> $day = $today['mday'];
> $datetoday = $year-$month-$day;
>
> include('../includes/conn.php');
> $insertFB = "INSERT INTO tblFeedback
> (fbName,fbEmail,fbType,fbDetails,fbDate) VALUES
>
> ('$_POST['fbName']','$_POST['fbEmail']','$_POST['fbType']','$_POST['fbDe
> tails']','$datetoday')";
> $resInsertFB = pg_query($connection,$insertFB);
> <--------
>
> I tried to create the $datetoday string because I kept getting errors
> telling me that my database field was a 'date' field and my date() value
> was an integrer. With this current version I get the following error:
>
> ------->
> Warning: pg_query() [function.pg-query]: Query failed: ERROR: Bad date
> external representation '1974' . in
> /usr/local/etc/apache_1.3.27/htdocs/feedback/feedback2.php on line 16
> Error:
> ERROR: Bad date external representation '1974'
> <------
> I'm pretty new to both PHP and postgres so any help provided would be
> gratefully received.
>
> Cheers,
> Matt
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>