I'm very new to php and mysql! So I need you help please!
I want to make a login/registration page and I found a tutorial. But everytime I want to import the table.sql into the database I get the following error:
#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 '( `id` int (5) NOT
NULL auto_increment, `usr` varchar (32) NOT NULL defaul' at line 4
This is the code of the table:
--
-- Table structure for table `tz_members`
--
CREATE DATABASE IF NOT EXISTS `tz_members` (
`id` int( 5 ) NOT NULL AUTO_INCREMENT ,
`usr` varchar( 32 ) NOT NULL default,
`pass` varchar( 32 ) NOT NULL default,
`email` varchar( 255 ) NOT NULL default,
`regIP` varchar( 15 ) NOT NULL default,
`dt` datetime NOT NULL default '0000-00-00 00:00:00',
PRIMARY KEY ( `id` ) ,
UNIQUE KEY ( `usr` )
) ENGINE = MYISAM DEFAULT CHARSET = utf8 COLLATE = utf8_unicode_ci AUTO_INCREMENT =6;
I hope you can help me! Thanks guys!
First its create table not create database
Now the syntax has a lot of errors like
usr` varchar( 32 ) NOT NULL default,
When you specify default you need to add a value for example you have done it for
`dt` datetime NOT NULL default '0000-00-00 00:00:00',
Here is the correct syntax
CREATE table IF NOT EXISTS `tz_members` (
`id` int(5) NOT NULL AUTO_INCREMENT ,
`usr` varchar(32) NOT NULL ,
`pass` varchar(32) NOT NULL ,
`email` varchar(255) NOT NULL ,
`regIP` varchar(15) NOT NULL ,
`dt` datetime NOT NULL default '0000-00-00 00:00:00',
PRIMARY KEY (`id`) ,
UNIQUE KEY (`usr`)
) ENGINE MYISAM DEFAULT CHARSET = utf8 COLLATE = utf8_unicode_ci AUTO_INCREMENT =6;
It should be CREATE TABLE and not CREATE DATABASE.
Also since you are not providing default values for all columns , you have to remove default keyword from these columns.
CREATE DATABASE IF NOT EXISTS `tz_members` (
`id` int( 5 ) NOT NULL AUTO_INCREMENT ,
`usr` varchar( 32 ) NOT NULL,
`pass` varchar( 32 ) NOT NULL,
`email` varchar( 255 ) NOT NULL,
`regIP` varchar( 15 ) NOT NULL,
`dt` datetime NOT NULL default '0000-00-00 00:00:00',
PRIMARY KEY ( `id` ) ,
UNIQUE KEY ( `usr` )
) ENGINE = MYISAM DEFAULT CHARSET = utf8 COLLATE = utf8_unicode_ci AUTO_INCREMENT =6;