Results 1 to 5 of 5
Thread: MySql Syntax
-
04-19-2004, 11:46 AM #1New Member
- Join Date
- Apr 2004
- Posts
- 1
MySql Syntax
CREATE TABLE `jokes` (
`id` INT( 5 ) NOT NULL AUTO_INCREMENT ,
`joke` MEDIUMBLOB( 500 ) NOT NULL ,
`dateaddedd` TIMESTAMP( YYYYMMDDHHSSMM ) NOT NULL ,
UNIQUE (
`id`
)
)
im using phpmyadmin, and i cant understand what is wrong withit, although I am no professional, and I havent used the timestamp before!
So help me please!
Thanks,
Punk$tar
-
04-19-2004, 01:18 PM #2WHT Addict
- Join Date
- Apr 2004
- Posts
- 104
Re: MySql Syntax
Originally posted by punk$star
CREATE TABLE `jokes` (
`id` INT( 5 ) NOT NULL AUTO_INCREMENT ,
`joke` MEDIUMBLOB( 500 ) NOT NULL ,
`dateaddedd` TIMESTAMP( YYYYMMDDHHSSMM ) NOT NULL ,
UNIQUE (
`id`
)
)
im using phpmyadmin, and i cant understand what is wrong withit, although I am no professional, and I havent used the timestamp before!
So help me please!
Thanks,
Punk$tar
PHP Code:`dateaddedd` TIMESTAMP( YYYYMMDDHHSSMM ) NOT NULL ,
PHP Code:`dateaddedd` DATETIME,
0000-00-00 00:00:00
UNLESS you specifically set a timestamp to insert in that format
(in PHP I simply do this
PHP Code:$stamp=date("Y-m-d H:i:s");
simple and painless.
-
04-19-2004, 02:44 PM #3WHT Addict
- Join Date
- Oct 2003
- Posts
- 124
Life becomes a lot easier if you store your dates as integers.
If you're using PHP to talk to mysql, see the strtotime, date, and the various other time/date functions. Easy as pie, plus much easier to write queries that do comparison (i.e. WHERE mydate=$somedate).
-
04-19-2004, 02:49 PM #4WHT Addict
- Join Date
- Aug 2003
- Location
- PA
- Posts
- 110
Like mktime() which responds with the current unix timestamp. The field would be a int(10). You wouldn't have to format until you drew it out again with the date() function.
You could use either response above, based on your needs, or the project requirements.
Bye
-
04-20-2004, 02:52 AM #5Web Hosting Master
- Join Date
- Jul 2003
- Location
- Kuwait
- Posts
- 5,104
Well, if you would post what error it was giving you that would help.
After a cursory glance, I can offer a few suggestions.
I believe MySQL has a requriement that any auto increment field must be a primary key. Add primary key (id) to your query and run it again.
Post the error so people can provide more targeted help.