SQL query error #1064 without any obvious error - mysql

I'm scratching my head over this error. I'm trying to import a sql file through phpmyadmin and it comes up with this errors one after another and I cannot sea anything wrong with it. Can someone please analyse the lines below and let me know if they see any errors?
Thank you
--
-- Table structure for table `jos_address_members`
--
CREATE TABLE IF NOT EXISTS `jos_address_members` (
`uid` int(10) unsigned NOT NULL DEFAULT '0',
`adid` int(10) unsigned NOT NULL DEFAULT '0',
`publish` tinyint(4) NOT NULL DEFAULT '1',
`ordering` tinyint(3) unsigned NOT NULL DEFAULT '9',
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
MySQL said: Documentation
#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 ') ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci' at line 12

Remove the comma after DEFAULT '9'
CREATE TABLE IF NOT EXISTS `jos_address_members` (
`uid` int(10) unsigned NOT NULL DEFAULT '0',
`adid` int(10) unsigned NOT NULL DEFAULT '0',
`publish` tinyint(4) NOT NULL DEFAULT '1',
`ordering` tinyint(3) unsigned NOT NULL DEFAULT '9'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

Related

MySQL said: Documentation #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version

I'm trying to import a SQL file into the database but facing this error. Please help if anyone can solve this error.
SQL query:
CREATE TABLE IF NOT EXISTS `products` (
`id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL,
`details` json NOT NULL,
`expiration_date` date ,
`barcode` varchar(125) COLLATE utf8mb4_unicode_ci,
`name` varchar(125) COLLATE utf8mb4_unicode_ci NOT NULL,
`bundle_id` bigint(20) UNSIGNED NOT NULL,
`shelf_id` bigint(20) UNSIGNED DEFAULT NULL,
`delivery_request_id` bigint(20) UNSIGNED DEFAULT NULL,
`status` int(11) NOT NULL DEFAULT '0',
`quantity` int(11) NOT NULL DEFAULT '1',
`weight` int(10) UNSIGNED NOT NULL,
PRIMARY KEY (`id`),
KEY `products_bundle_id_foreign` (`bundle_id`),
KEY `products_shelf_id_foreign` (`shelf_id`),
KEY `products_delivery_request_id_foreign` (`delivery_request_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
MySQL said: Documentation
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'json NOT NULL,
`expiration_date` date ,
`barcode` varchar(125) COLLATE utf8m' at line 5

Syntax error creating table

When i try to create table using the below code,
CREATE TABLE `audit` (
`audit_id` int(10) unsigned NOT NULL auto_increment,
`order_id` int(11) NOT NULL default '0',
`datestamp` datetime NOT NULL default '0000-00-00 00:00:00',
`message` text NOT NULL,
`message_number` int(11) NOT NULL default '0',
PRIMARY KEY (`audit_id`)
) TYPE=MyISAM AUTO_INCREMENT=196 ;
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 'TYPE=MyISAM AUTO_INCREMENT=8'
Can someone help me to rectify the error?
Thanks
yes... use ENGINE instead TYPE like this
CREATE TABLE `category` (
`category_id` int(10) unsigned NOT NULL auto_increment,
`department_id` int(10) unsigned NOT NULL default '0',
`name` varchar(50) NOT NULL default '',
`description` varchar(200) default NULL,
PRIMARY KEY (`category_id`)
) ENGINE=MyISAM

MySQL Dump Not Importing

I did a SQL Dump from my MySQL [version 5.6.12] a few days ago now I am trying to import back to the same DB.
The line
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
is not working, it throws a
#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 ') ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1' error.
I have tripple checked the syntax, and even copped and pasted from one of the other tables that successfully import.
not sure what could be wrong.
here is the full SQL: http://pastebin.com/hrBKv7Su.
NOTE: I know there are simlar posts none have helped so far.
When faced with a 1064 error that points to a specific location, look to the character or word right before it. There, you'll find an errant trailing comma in this case.
CREATE TABLE IF NOT EXISTS `item` (
`id` mediumint(8) UNSIGNED NOT NULL AUTO_INCREMENT,
`name` VARCHAR(11) NOT NULL,
`string` VARCHAR(30) NOT NULL,
`price` DECIMAL(9,2) NOT NULL,
`note` VARCHAR(500) DEFAULT NULL,
`categoryId` SMALLINT(5) UNSIGNED NOT NULL,
`printerId` tinyint(3) NULL DEFAULT NULL,
`hidden` tinyint(1) NOT NULL DEFAULT '0',
`inStock` tinyint(1) NOT NULL DEFAULT '1',
PRIMARY KEY (`id`),
KEY `categoryId` (`categoryId`,`printerId`),
KEY `printerId` (`printerId`),
/* -------------------------^^^ remove that comma */
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

#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?
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;

Latest version of MySQL gives error 1064 on code that used to work fine

Many servers now a days have the latest version of MySQL - which is giving an error when running the following piece of code:
$drop_table = mysql_query("DROP TABLE IF EXISTS `$t_ads`");
$sqls[$t_ads] = "CREATE TABLE `$t_ads` (
`adid` int unsigned NOT NULL auto_increment,
`adtitle` varchar(100) NOT NULL default '',
`addesc` longtext NOT NULL,
`area` varchar(50) NOT NULL default '',
`email` varchar(50) NOT NULL default '',
`showemail` enum('0','1','2') NOT NULL default '0',
`password` varchar(50) NOT NULL default '',
`code` varchar(35) NOT NULL default '',
`cityid` smallint unsigned NOT NULL default '0',
`subcatid` smallint unsigned NOT NULL default '0',
`price` DECIMAL( 10, 2 ) NOT NULL default '0',
`othercontactok` enum('0','1') NOT NULL default '0',
`hits` int unsigned NOT NULL default '0',
`ip` varchar(15) NOT NULL default '',
`verified` enum('0','1') NOT NULL default '0',
`abused` int unsigned NOT NULL default '0',
`enabled` enum('0','1') NOT NULL default '0',
`createdon` datetime NOT NULL default '0000-00-00 00:00:00',
`expireson` datetime NOT NULL default '0000-00-00 00:00:00',
`timestamp` timestamp(14) NOT NULL,
`paid` enum('0','1','2') NOT NULL default '2',
PRIMARY KEY (`adid`),
KEY `subcatid` (`subcatid`),
KEY `cityid` (`cityid`),
KEY `verified` (`verified`),
KEY `enabled` (`enabled`),
KEY `paid` (`paid`)
) TYPE=MyISAM;";
Servers with an older version of mysql seem to accept this, but the new version is not accepting it at all and giving an error. I have many errors related to it since the PHP database setup is little bigger. An example of the error is below:
#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, paid enum, NOT NULL default '2', PRIMARY KEY (adid), K' at line 21
The plain SQL part of your code looks ok (just tested it with MySQL 5.6), though I'd generally advise not to use keywords like timestamp as a column name. The table will be created in MySQL 5.6, but you'll encounter two warnings:
The syntax TIMESTAMP(14) is deprecated and will be removed in
MySQL 6.0. Please use TIMESTAMP instead
The syntax TYPE=storage_engine is deprecated and will be removed in MySQL
6.0. Please use ENGINE=storage_engine instead
If this doesn't help, please post the actual MySQL version you're working with.
Change your column name it should not be mysql keyword 'timestamp' and
chnage
`timestamp` timestamp(14) NOT NULL,
to
`<SOME OTHERNAME>` timestamp NOT NULL,