Page 1 of 1

Need help creatin a table

Posted: Fri Jun 29, 2007 6:09 pm
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

Posted: Fri Jun 29, 2007 6:49 pm
by Ambush Commander
Try adding spaces between the column name and the column data type.

Posted: Fri Jun 29, 2007 6:55 pm
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.

Posted: Fri Jun 29, 2007 6:56 pm
by Ambush Commander
Did it work?

Posted: Fri Jun 29, 2007 6:57 pm
by superdezign
Still not working? Take the "primary key" part off of the id field, and then later on add "primary key(id)"

Posted: Fri Jun 29, 2007 6:58 pm
by Maluendaster
Ambush Commander wrote:Did it work?
no, it didn't... :(

Posted: Fri Jun 29, 2007 7:30 pm
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

Posted: Fri Jun 29, 2007 7:34 pm
by Ambush Commander
I know why: CONDITION is a MySQL keyword. Add backticks (`) around all your column names, and it should work.

Posted: Fri Jun 29, 2007 7:52 pm
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!

Posted: Fri Jun 29, 2007 9:02 pm
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