views:

25

answers:

2
create table snippet(
id int not null auto_increment,
primary key(id),
idlanguage int not null,
foreign key(idlanguage) references language(id),
iduser int not null,
foreign key(iduser) references user(id),
title varchar(200) not null,
content varchar(max) not null,
rating int,
creationdate datetime
);

I'm getting an error at line 9 near 'max)' according to PHPMyAdmin.

Thank you for the help.

A: 

I don't think that "max" is a valid value for the maximum number of character that can be put in your content column : you should specify a numerical value.

But note that varchar has a limited maximum length (see the varchar page in the MYSQL's manual for the details) -- which means it might not be the best data-type for a "content" column.

A possibibly better solution might be to use one of the TEXT data-type :

...
content TEXT not null, 
...

TEXT columns can contain strings that are a lot longer than varchar ; for more informations, see 10.4.3. The BLOB and TEXT Types.

Pascal MARTIN
@Lex I was just searching through the manual for the exact value when you posted your comment -- I've edited my answer to remove the values, and put a link to the manual ;; basically, the maximum size of a varchar depends on the size of the other columns of the row, it seems.
Pascal MARTIN
+1  A: 

VARCHAR(MAX) is an MS SQL Server extension to the SQL language -- it does not exist in mysql. Put a number there and you will be golden.

Hogan