Discuss Beginner error when creating table in the MySQL Help forum on Dev Shed. Beginner error when creating table MySQL Help forum discussing administration, SQL syntax, and other MySQL-related topics. MySQL is an open-source relational database management system (RDBMS).
Receive the tools necessary to be the rock star of your field. Our 12-month program teaches you the evolving world of multi-channel marketing as well as the complex issues and opportunities found in the industry.
ASP Free and Iron Speed Designer are giving away $5,500+ in FREE licenses. Iron Speed's RAD CASE toolset can save up to 80% of your coding time. One free license per week, one perpetual license per month! Download and Activate to enter!
Web development can be a daunting task, even for specialists. There is a lot of information to absorb and a lot of technologies to learn in order to manage a superior website. When trying to learn the ropes, developers need a reliable source to introduce new ideas that can be easily implemented. When working on large projects, even web veterans may run into a technology or an aspect of a technology that they are unfamiliar with.
Posts: 14
Time spent in forums: 6 h 38 m 59 sec
Reputation Power: 0
Beginner error when creating table
I have a database and a table that I'm creating for a joomla component but whenever I install the component I get an error in the database, can someone please tell me what I'm doing wrong?
Code:
DROP TABLE IF EXISTS `#__accordion`;
CREATE TABLE `#__accordion` (
`id` int(11) unsigned NOT NULL auto_increment,
`greeting` varchar(25) NOT NULL,
'title' varchar(125) NOT NULL,
'price' money NOT NULL,
'description' varchar(125) NOT NULL,
'image' varchar(125) NOT NULL,
PRIMARY KEY (`id`))
ENGINE=MyISAM AUTO_INCREMENT=0 DEFAULT CHARSET=utf8;
INSERT INTO '#__accordion' (title, price, description) VALUES ('HTML is the best', '40', 'Book to learn HTML');
There are a few questions I have as well... I'm not too sure what value to set for the image field. I hear the best way to do it is to store a link in the image row... I'm just not sure how to do it.
I will appreciate any help! I have been looking on different tutorials but I keep getting errors.
Posts: 14
Time spent in forums: 6 h 38 m 59 sec
Reputation Power: 0
This is the error that I get:
JInstaller: :Install: Error SQL DB function failed with error number 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 ''title' varchar(125) NOT NULL, 'price' money NOT NULL, 'description' var' at line 4 SQL=CREATE TABLE `jos_accordion` ( `id` int(11) unsigned NOT NULL auto_increment, `greeting` varchar(25) NOT NULL, 'title' varchar(125) NOT NULL, 'price' money NOT NULL, 'description' varchar(125) NOT NULL, 'image' varchar(125) NOT NULL, PRIMARY KEY (`id`)) ENGINE=MyISAM AUTO_INCREMENT=0 DEFAULT CHARSET=utf8; "
Posts: 14
Time spent in forums: 6 h 38 m 59 sec
Reputation Power: 0
Code:
DROP TABLE IF EXISTS `#__accordion`;
CREATE TABLE `#__accordion` (
id int(11) unsigned NOT NULL auto_increment,
greeting varchar(25) NOT NULL,
title varchar(125) NOT NULL,
price int(100) NOT NULL,
description varchar(125) NOT NULL,
image varchar(125) NOT NULL,
PRIMARY KEY (`id`))
ENGINE=MyISAM AUTO_INCREMENT=0 DEFAULT CHARSET=utf8;
INSERT INTO `#__accordion` (greeting, title, price, description, image) VALUES ('Hello'), ('BookName'), ('40'), ('this is description') ('image');
Posts: 14
Time spent in forums: 6 h 38 m 59 sec
Reputation Power: 0
Quote:
Originally Posted by kimmi_baby
Code:
DROP TABLE IF EXISTS `#__accordion`;
CREATE TABLE `#__accordion` (
id int(11) unsigned NOT NULL auto_increment,
greeting varchar(25) NOT NULL,
title varchar(125) NOT NULL,
price int(100) NOT NULL,
description varchar(125) NOT NULL,
image varchar(125) NOT NULL,
PRIMARY KEY (`id`))
ENGINE=MyISAM AUTO_INCREMENT=0 DEFAULT CHARSET=utf8;
INSERT INTO `#__accordion` (greeting, title, price, description, image) VALUES ('Hello'), ('BookName'), ('40'), ('this is description') ('image');
I'm getting errors with my insert now...
I fixed it with this
Code:
DROP TABLE IF EXISTS `#__accordion`;
CREATE TABLE `#__accordion` (
id int(11) unsigned NOT NULL auto_increment,
greeting varchar(25) NOT NULL,
title varchar(125) NOT NULL,
price int(100) NOT NULL,
description varchar(125) NOT NULL,
image varchar(125) NOT NULL,
PRIMARY KEY (`id`))
ENGINE=MyISAM AUTO_INCREMENT=0 DEFAULT CHARSET=utf8;
INSERT INTO `#__accordion` (greeting, title, price, description, image) VALUES ('Hello', 'BookName', 40, 'this is description', 'image');