PDA

View Full Version : maximum length for text column


pardicity3
04-23-2003, 07:40 PM
I am attempting to make a php/mysql script that will allow me to easily update my online log. The problem is that when trying to set up a mysql table to hold my data I keep getting an error when trying to make a text column with a maximum length of 65000 (I think that is the max for text right?). This is the error I get (I am using phpmyadmin):

SQL-query :

CREATE TABLE `log` (

`id` INT( 6 ) NOT NULL AUTO_INCREMENT,
`title` VARCHAR( 100 ) NOT NULL ,
`date` VARCHAR( 100 ) NOT NULL ,
`message` TEXT( 65000 ) NOT NULL ,
INDEX ( `id` )
)

MySQL said:


You have an error in your SQL syntax near '(65000) NOT NULL, INDEX (`id`))' at line 1

I don't know enough about mysql to figure any of this out :). I do know that the problem is deffinelty with the message column as if I leave it out I don't get an error. I would assume that I am perhaps specifying to great of a length but it won't even work at 10000.

Maybe I need to make the column null or something? I don't know :confused: . I don't even know what null means when it applies to a mysql table...oh dear, I am soo lost!

Dylan Leblanc
04-23-2003, 09:46 PM
You don't have to specify the length of a text column.

raf
04-23-2003, 09:49 PM
The problem is that you can't specify the length of a variable from datatype text. (so just drop the length. But you'll probably need mediumtext or mediumblob.

More info on create table and datatypes:
http://www.mysql.com/doc/en/CREATE_TABLE.html
http://www.mysql.com/doc/en/String_types.html
<edit>posts crossed</edit>

pardicity3
04-23-2003, 10:07 PM
wonderful, just dropped the length and it worked perfectly. Just wondering, but does this mean that I don't ever have to specify a length, or is this just for text and blob? (Oh and I did change to mediumtext, it was a better idea)

raf
04-24-2003, 07:20 AM
this mean that I don't ever have to specify a length
No. Absolutely not. If you know trhe length of the values that will be inserted, then always specify the length when you create the variable. Fot more info, check out the links and browse around at the MySQL site