Page 1 of 1

Error in syntax

Posted: Tue Mar 27, 2007 11:19 am
by wildwobby
I just tried creating a table in phpMyAdmin and it executed the following SQL:

Code: Select all

 CREATE TABLE `pireps` (
`piid` INT( 5 ) NOT NULL AUTO_INCREMENT ,
`pid` INT( 5 ) NOT NULL ,
`fid` INT( 5 ) NOT NULL ,
`hrs` DOUBLE( 5 ) NOT NULL ,
`comments` TEXT( 5000 ) NOT NULL ,
`filed` TIMESTAMP( 12 ) NOT NULL ,
`marked` TIMESTAMP( 12 ) NOT NULL ,
`status` TINYINT( 3 ) NOT NULL ,
PRIMARY KEY ( `piid` ) ,
INDEX ( `pid` )
) 
However, it is returning the error:
#1064 - You have an error in your SQL syntax near ') NOT NULL, `comments` TEXT(5000) NOT NULL, `filed` TIMESTAMP(12) NOT NULL, `mar' at line 1
Whats the problem?

Posted: Tue Mar 27, 2007 11:26 am
by onion2k
I don't often use DOUBLE columns, so I'm not 100% sure, but if you specify the number of digits don't you also have to specify the number of decimal places?

Also, is 'hrs' short for 'hours'? If it is then I doubt you really need a DOUBLE anyway. A DECIMAL would suit the data much better.

Posted: Tue Mar 27, 2007 2:12 pm
by Begby
TEXT doesn't take a dimension, that is probably why you are getting the error.

Also, if you are storing the hours as a decimal and if you need to turn them back to minutes, then you will have issues with how floats are handled. It gets very weird. You are better off storing the hours as seconds.