Need help creatin a table

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
Maluendaster
Forum Contributor
Posts: 124
Joined: Fri Feb 25, 2005 1:14 pm

Need help creatin a table

Post by Maluendaster »

hi all, I'm in phpMyAdmin and trying to create a table, here it is :

Code: Select all

CREATE TABLE vehicle_inventory(
id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,
ccode NUMERIC( 15 ) ,
added NUMERIC( 10 ) ,
updated NUMERIC( 10 ) ,
viewed NUMERIC( 10 ) ,
numimages NUMERIC( 2 ) ,
stockCHAR( 20 ) ,
vinCHAR( 30 ) ,
year NUMERIC( 4 ) ,
makeCHAR( 20 ) ,
modelCHAR( 30 ) ,
conditionCHAR( 4 ) ,
categoryCHAR( 20 ) ,
mileageCHAR( 9 ) ,
priceCHAR( 15 ) ,
exteriorCHAR( 30 ) ,
interiorCHAR( 30 ) ,
bodyCHAR( 20 ) ,
doorsCHAR( 1 ) ,
ENGINE CHAR( 40 ) ,
fuelCHAR( 20 ) ,
transCHAR( 20 ) ,
stereoCHAR( 40 ) ,
comments TEXT
)
and this is the error that gave me, I've done this before, and i've never had that problem. Anyone knows?
#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 'condition CHAR(4),
category CHAR(20),
mileage CHAR(9),
price CHAR(15),
e' at line 12
Im using PHP Version 5.2.2 and phpMyAdmin - 2.10.1
User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

Post by Ambush Commander »

Try adding spaces between the column name and the column data type.
Maluendaster
Forum Contributor
Posts: 124
Joined: Fri Feb 25, 2005 1:14 pm

Post by Maluendaster »

Ambush Commander wrote:Try adding spaces between the column name and the column data type.

Code: Select all

CREATE TABLE vehicle_config (id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
	ccode NUMERIC(15),
	added NUMERIC(10),
	updated NUMERIC(10),
	viewed NUMERIC(10),
	numimages NUMERIC(2),
	stock CHAR(20),
	vin CHAR(30),
	year NUMERIC(4),
	make CHAR(20),
	model CHAR(30),
	condition CHAR(4),
	category CHAR(20),
	mileage CHAR(9),
	price CHAR(15),
	exterior CHAR(30),
	interior CHAR(30),
	body CHAR(20),
	doors CHAR(1),
	engine CHAR(40),
	fuel CHAR(20),
	trans CHAR(20),
	stereo CHAR(40),
	comments TEXT
	)
I already did that, in fact, the first post i did, don't know why it ate the spaces, this is the actual table config. that's doesnt work.
User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

Post by Ambush Commander »

Did it work?
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Post by superdezign »

Still not working? Take the "primary key" part off of the id field, and then later on add "primary key(id)"
Maluendaster
Forum Contributor
Posts: 124
Joined: Fri Feb 25, 2005 1:14 pm

Post by Maluendaster »

Ambush Commander wrote:Did it work?
no, it didn't... :(
Maluendaster
Forum Contributor
Posts: 124
Joined: Fri Feb 25, 2005 1:14 pm

Post by Maluendaster »

superdezign wrote:Still not working? Take the "primary key" part off of the id field, and then later on add "primary key(id)"
nop, that didn't work... thnks for your help.

I created the Database MOTOS

then I made 3 tables
vehicle_imagelist

Code: Select all

CREATE TABLE vehicle_config (id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
	username CHAR(20),
	password CHAR(20),
	installed NUMERIC(10),
	dealer CHAR(60),
	email CHAR(60),
	phone CHAR(15)
	)
That one was OK

vehicle_imagelist

Code: Select all

CREATE TABLE $dbimg (id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
	ccode NUMERIC(15),
	thumb CHAR(23),
	image CHAR(23)
	)
That one was also OK

Now I want to create the third table, this one gives me the errors:

vehicle_inventory

Code: Select all

CREATE TABLE vehicle_inventory (id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
	ccode NUMERIC(15),
	added NUMERIC(10),
	updated NUMERIC(10),
	viewed NUMERIC(10),
	numimages NUMERIC(2),
	stock CHAR(20),
	vin CHAR(30),
	year NUMERIC(4),
	make CHAR(20),
	model CHAR(30),
	condition CHAR(4),
	category CHAR(20),
	mileage CHAR(9),
	price CHAR(15),
	exterior CHAR(30),
	interior CHAR(30),
	body CHAR(20),
	doors CHAR(1),
	engine CHAR(40),
	fuel CHAR(20),
	trans CHAR(20),
	stereo CHAR(40),
	comments TEXT
	)
In this one the error that gives me when I click Continue is : (i'll copy paste) , and please note that the spaces between dissapear (in some of them):

Code: Select all

Error

consulta SQL:

CREATE TABLE vehicle_inventory(
id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,
ccode NUMERIC( 15 ) ,
added NUMERIC( 10 ) ,
updated NUMERIC( 10 ) ,
viewed NUMERIC( 10 ) ,
numimages NUMERIC( 2 ) ,
stockCHAR( 20 ) ,
vinCHAR( 30 ) ,
year NUMERIC( 4 ) ,
makeCHAR( 20 ) ,
modelCHAR( 30 ) ,
conditionCHAR( 4 ) ,
categoryCHAR( 20 ) ,
mileageCHAR( 9 ) ,
priceCHAR( 15 ) ,
exteriorCHAR( 30 ) ,
interiorCHAR( 30 ) ,
bodyCHAR( 20 ) ,
doorsCHAR( 1 ) ,
ENGINE CHAR( 40 ) ,
fuelCHAR( 20 ) ,
transCHAR( 20 ) ,
stereoCHAR( 40 ) ,
comments TEXT
)

MySQL ha dicho: Documentación
#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 'condition CHAR(4),
category CHAR(20),
mileage CHAR(9),
price CHAR(15),
exter' at line 12
User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

Post by Ambush Commander »

I know why: CONDITION is a MySQL keyword. Add backticks (`) around all your column names, and it should work.
Maluendaster
Forum Contributor
Posts: 124
Joined: Fri Feb 25, 2005 1:14 pm

Post by Maluendaster »

Ambush Commander wrote:I know why: CONDITION is a MySQL keyword. Add backticks (`) around all your column names, and it should work.
thanks! id worked! you're my code hero!!! yeah.. congratulations to you!
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

This doesn't have anything to do with PHP. :? Moved to Databases.

Code: Select all

select blah blah

Code: Select all

select blah blah
Post Reply