Question

CREATE TABLE IF NOT EXISTS `users` ( 
`id` int(11) NOT NULL auto_increment, 
`username` varchar(32) NOT NULL, 
`password` varchar(32) NOT NULL, 
`online` int(20) NOT NULL default '0′, 
`email` varchar(100) NOT NULL, 
`active` int(1) NOT NULL default '0′, 
`rtime` int(20) NOT NULL default '0′, 
PRIMARY KEY (`id`) 
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

This is the original phpmyadmin error message, when I enter the code shown above sql to create the table:

#1064 - 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 
'`password` varchar (32) NULL, `On-line` int NOT (20) NULL default '0 ', NON ' 
at line 4

I would like to understand how this code should be written correctly and what is wrong!

Pas de solution correcte

Autres conseils

You should remove strange '0′ quotes for int default values. This should work for you:

CREATE TABLE IF NOT EXISTS `users` (
    `id` int(11) NOT NULL auto_increment,
    `username` varchar(32) NOT NULL,
    `password` varchar(32) NOT NULL,
    `online` int(20) NOT NULL default 0,
    `email` varchar(100) NOT NULL,
    `active` int(1) NOT NULL default 0,
    `rtime` int(20) NOT NULL default 0,
    PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

The problem is that you are not closing you quotes correctly. You have '0′ instead of '0'.

You can either fix them of get rid of the quotes at all, since the columns are defined as integer.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top