Results 1 to 5 of 5

Thread: MySql Syntax

  1. #1

    Exclamation 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

  2. #2

    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
    I recommend using datetime, simply change this :
    PHP Code:
    `dateaddeddTIMESTAMPYYYYMMDDHHSSMM NOT NULL 
    to this:
    PHP Code:
    `dateaddeddDATETIME
    and it will automatically format to a default of YYY-MM-DD like this

    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"); 
    and you can insert $stamp right into your dateaddedd field.

    simple and painless.

  3. #3
    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).

  4. #4
    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

  5. #5
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •