RE: MySQL Date insert

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

 



	I actually think I know part of this answer...  I don't think you
need to define a variable to insert into your "date" field.  Inserting an
empty value into this filed will populate the field in the database with the
current time, which it appears from your code is what you are trying to do
here.  Try changing the field name and give that a shot.  I think I am
actually right here though.

Scott

-----Original Message-----
From: Hutchins, Richard [mailto:Richard.Hutchins@Getingeusa.com]
Sent: Monday, July 28, 2003 1:19 PM
To: php-db@lists.php.net
Subject: RE:  MySQL Date insert


Don't know about your date format, but you have named your table column DATE
which is a reserved keyword in MySQL. Try naming that something different
and see if you still get the error.

> -----Original Message-----
> From: Andrew D. Luebke [mailto:andrew@copeandmcphetres.com]
> Sent: Monday, July 28, 2003 2:17 PM
> To: php-db@lists.php.net
> Subject:  MySQL Date insert
> 
> 
> Hello,
>     I have the following PHP code:
> 
>          $date = date("Y-m-d H:i:s");
>          $result = mysql_query("INSERT INTO Boats (Make, 
> Model, Serial, 
> Stock, Extension, Cust_Name, Store, Date) VALUES
>                  ('$make', '$model', '$serial', '$stock', 
> '$extension', 
> '$name', '$store', '$date'")
>                  or die("Invalid query: " . mysql_error() . 
> "</body></html>");
> 
> The problem is with the Date column.  It is of type DATETIME. 
>  I get an 
> error on the second line of the insert statement.  I assume 
> I'm not putting 
> formatting the date-time variable correctly but I've tried 
> everything I can 
> think of, so any help is very much appreciated.  Thanks.
> 
> Andrew. 
> 

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux