Reputation: 41
i get this error when i try to inport to data base
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 '('id') ) TYPE=MyISAM AUTO_INCREMENT=6' at line 4
DROP TABLE IF EXISTS `categories`;
CREATE TABLE `categories` (
`id` int(5) NOT NULL auto_increment,
`category` varchar(50) NOT NULL default '',
PRIMARY KEY ('id')
) TYPE=MyISAM AUTO_INCREMENT=6 ;
Upvotes: 4
Views: 43369
Reputation: 1
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 'FROM disc_disc WHERE disc_id=NULL' at line 1 SQL=SELECT disc_id, disc_name, FROM disc_disc WHERE disc_id=NULL
// zjistit jmeno diskuse
$disc_name = "";
$sql = sprintf("SELECT disc_id, disc_name, " .
"FROM disc_disc " .
"WHERE disc_id=%s",
quote_smart($disc_id));
$db->setQuery($sql);
$rec = $db->loadObjectList();
if ($db->getErrorNum()) {
JError::raiseWarning( 500, $db->stderr() );
}
Upvotes: -2
Reputation:
Try this:
DROP TABLE IF EXISTS `categories`;
CREATE TABLE `categories` (
`id` int(5) NOT NULL auto_increment,
`category` varchar(50) NOT NULL default '',
PRIMARY KEY (`id`)
) ENGINE=MYISAM AUTO_INCREMENT=6
The problems is that PRIMARY KEY ('id')
should use backquotes insted of quotes
Upvotes: 2
Reputation: 51928
You are using '
here
PRIMARY KEY ('id')
id
is in this case a string, not the column name. Use backticks instead.
PRIMARY KEY (`id`)
Upvotes: 3
Reputation: 247860
You have two issues with the code, remove the single quotes around the id
in the primary key declaration. You can use backticks or nothing.
And change the Type=MyISAM
to:
ENGINE=MyISAM
From the MySQL Docs:
The older term TYPE is supported as a synonym for ENGINE for backward compatibility, but ENGINE is the preferred term and TYPE is deprecated.
So the script will be:
DROP TABLE IF EXISTS `categories`;
CREATE TABLE `categories` (
`id` int(5) NOT NULL auto_increment,
`category` varchar(50) NOT NULL default '',
PRIMARY KEY (id)
) ENGINE=MyISAM AUTO_INCREMENT=6 ;
Upvotes: 2