Error in syntax

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
wildwobby
Forum Commoner
Posts: 66
Joined: Sat Jul 01, 2006 8:35 pm

Error in syntax

Post 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?
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Post 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.
Begby
Forum Regular
Posts: 575
Joined: Wed Dec 13, 2006 10:28 am

Post 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.
Post Reply