Search code examples
mysqlsqlcreate-table

#1064 - You have an error in your SQL syntax '(14) NOT NULL, `ID_MEMBER` mediumint(8) unsigned NOT NULL default '0', `ip` ' at line 3


Im getting this error:

#1064 - You have an error in your SQL syntax; check the manual that corresponds 
to your MySQL server version for the right syntax to use near '(14) NOT NULL, 
`ID_MEMBER` mediumint(8) unsigned NOT NULL default '0', `ip` ' at line 3

When I run this script:

  CREATE TABLE IF NOT EXISTS `MVElog_online` (
  `session` varchar(32) NOT NULL default '0',
  `logTime` timestamp(14) NOT NULL,
  `ID_MEMBER` mediumint(8) unsigned NOT NULL default '0',
  `ip` int(10) unsigned NOT NULL default '0',
  `url` text NOT NULL,
  PRIMARY KEY  (`session`),
  KEY `logTime` (`logTime`),
  KEY `ID_MEMBER` (`ID_MEMBER`)
) ENGINE=MyISAM;

What does the error mean and what am I doing wrong?


Solution

  • timestamp should not have length, (It's timestamp not timestamp(14))

    CREATE TABLE IF NOT EXISTS `MVElog_online` (
      `session` varchar(32) NOT NULL default '0',
      `logTime` timestamp NOT NULL,                 -- HERE
      `ID_MEMBER` mediumint(8) unsigned NOT NULL default '0',
      `ip` int(10) unsigned NOT NULL default '0',
      `url` text NOT NULL,
      PRIMARY KEY  (`session`),
      KEY `logTime` (`logTime`),
      KEY `ID_MEMBER` (`ID_MEMBER`)
    ) ENGINE=MyISAM;