• Howdy! Welcome to our community of more than 130.000 members devoted to web hosting. This is a great place to get special offers from web hosts and post your own requests or ads. To start posting sign up here. Cheers! /Peo, FreeWebSpace.net
managed wordpress hosting

Whats wrong with this mySQL query?

coolblu

Member
Hello all :)

Just wondering if you can tell me where I am going wrong with this - bit of a newbie with mySQL :)

PHP:
CREATE TABLE `records` (

`id` INT( 7 ) NOT NULL AUTO_INCREMENT,
`cat` TEXT( 2 ) NOT NULL ,
`artistname` TEXT( 40 ) NOT NULL ,
`title` TEXT( 45 ) NOT NULL ,
`price` TEXT( 6 ) NOT NULL ,
`year` YEAR( 4 ) NOT NULL ,
`rcon` TEXT( 2 ) NOT NULL ,
`scon` TEXT( 2 ) NOT NULL ,
`desc` TEXT( 150 ) NOT NULL ,
PRIMARY KEY ( `id` ) ,
INDEX ( `cat` , `artistname` , `title` , `price` , `year` , `rcon` , `scon` , `desc` ) 
)


Hope you can help :D

Thanks
 
i don't think 'text' can be assigned a limiter, at least i never do. i think it's preset to 16kb or whatever it may be, but i'm probably wrong.

try using either 'char()' or 'varchar()', or just plain 'text':

PHP:
CREATE TABLE records (
id INT(7) NOT NULL PRIMARY KEY AUTO_INCREMENT,
cat VARCHAR(2) NOT NULL,
artistname VARCHAR(40) NOT NULL,
title VARCHAR(45) NOT NULL,
price VARCHAR(6) NOT NULL,
year VARCHAR(4) NOT NULL,
rcon VARCHAR(2) NOT NULL,
scon VARCHAR(2) NOT NULL,
desc VARCHAR(150) NOT NULL
)
 
I still get this with that code keith:

PHP:
Error

SQL-query :  

CREATE TABLE records(

id INT( 7 ) NOT NULL PRIMARY KEY AUTO_INCREMENT,
cat VARCHAR( 2 ) NOT NULL ,
artistname VARCHAR( 40 ) NOT NULL ,
title VARCHAR( 45 ) NOT NULL ,
price VARCHAR( 6 ) NOT NULL ,
year VARCHAR( 4 ) NOT NULL ,
rcon VARCHAR( 2 ) NOT NULL ,
scon VARCHAR( 2 ) NOT NULL ,
DESC VARCHAR( 150 ) NOT NULL 
) 

MySQL said: 


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 'DESC VARCHAR( 150  )  NOT  NULL  )' at line 1
Back

I cant figure out where any of it is going wrong :confused2
 
This works:


PHP:
CREATE TABLE `records` (
`id ` INT( 7 ) NOT NULL AUTO_INCREMENT,
`cat ` VARCHAR( 2 ) NOT NULL ,
`artistname ` VARCHAR( 40 ) NOT NULL ,
`title ` VARCHAR( 45 ) NOT NULL ,
`price ` VARCHAR( 6 ) NOT NULL ,
`year ` VARCHAR( 4 ) NOT NULL ,
`rcon ` VARCHAR( 2 ) NOT NULL ,
`scon ` VARCHAR( 2 ) NOT NULL ,
`DESC ` VARCHAR( 150 ) NOT NULL ,
PRIMARY KEY ( `id ` ) 
);
 
Back
Top