1.

Solve : MySQL Create Table Error?

Answer»

CREATE TABLE users (
user_id INT UNSIGNED NOT NULL AUTO_INCREMENT,
first_name VARCHAR(20) NOT NULL,
last_name VARCHAR(40) NOT NULL,
email VARCHAR(80) NOT NULL,
pass CHAR(40) NOT NULL,
user_level TINYINT(1) UNSIGNED NOT NULL DEFAULT 0,
active CHAR(32),
registration_date DATETIME NOT NULL,
PRIMARY KEY (user_id),
UNIQUE KEY (email),
INDEX login (email, pass)
);




ERROR -

CREATE TABLE users(

user_id INT UNSIGNED NOT NULL AUTO_INCREMENT ,
first_name VARCHAR( 20 ) NOT NULL ,
last_name VARCHAR( 40 ) NOT NULL ,
email VARCHAR( 80 ) NOT NULL ,
passCHAR( 40 ) NOT NULL ,
user_level TINYINT( 1 ) UNSIGNED NOT NULL DEFAULT 0,
activeCHAR( 32 ) ,
registration_date DATETIME NOT NULL ,
PRIMARY KEY ( user_id ) ,
UNIQUE KEY ( email ) ,
INDEX login( email, pass )
)

MySQL said: 

#1046 - No database selected
Hi
Actually I am not expert in DB, but as I know a little bit about MYSQL, first of all you have to create a database and then start to create a table.Are you using PHP to create these tables, or are you using PHPMyAdmin, ETC.?

http://www.w3schools.com/php/php_mysql_create.aspare you using MySQL database??

after you input the password:
TYPE -> show databases;
and then all the databases will APPEAR, and then you NEED to select one which is your database
type -> use mydatabase;

and then,, that's it,,,, input the query in creating your table.....



Please don't post links to your site
Ok, I fixed it.

Thanks guys!

 
 
 
 
 



Discussion

No Comment Found