Web Hosting Talk







View Full Version : mySQL error... confused =S


crEA-tEch
01-29-2004, 03:10 PM
Hey guys, me again...

I'm getting the error:

Error

SQL-query :

CREATE TABLE tod_company_informaion(

company_id int( 25 ) NOT NULL auto_increment,
company_name varchar NOT NULL default '',
company_contact_name varchar NOT NULL default '',
company_address varchar NOT NULL default '',
company_post_code varchar NOT NULL default '',
company_telephone_number varchar NOT NULL default '',
PRIMARY KEY ( company_id ) ,

) TYPE = MYISAM COMMENT = 'Tods Tyres - Company Information'

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 'NOT NULL default '', company_contact_name varchar NOT NULL d

Now I'm sure as damn theres nothing wrong with that SQL...

Can anyone help?

Thanks in advance

probonic
01-29-2004, 04:00 PM
Was that generated by phpMyAdmin?

I have tried that SQL code and it does the same for me (doing it directly from the command line.)

It seems to be a problem not with that first varchar field, but with the "NOT NULL" on all of them, because I deleted that first one and it did the same with the rest.

**EDIT: I have just created a table in phpMyAdmin and it wouldn't allow me to not select a length for the varchar. So I think you need to give it lengths for the varchar's, i.e. varchar(x).

crEA-tEch
01-29-2004, 04:10 PM
thanks probonic! you've been a great help, it works fine :)

crE

probonic
01-29-2004, 04:14 PM
Glad to hear it :)

Sheps
01-30-2004, 01:18 AM
Yes, varchar's need a length for the field, it can be upto 255, IIRC...

I also had that happen to me once, and adding a length fixed it. Although, it would be nice if it had a default value incase that wasn't set...