user1621945
user1621945

Reputation: 35

MySQL throwing error on create table. No idea why

$invited = "CREATE TABLE invited (id NOT NULL AUTO_INCREMENT, PRIMARY KEY (id), name VARCHAR(255), email VARCHAR(255), permissions VARCHAR(255))";
mysqli_query($dbc, $invited) or die ('Error creating invited');

What is wrong with this code? Keeps giving me "Error creating invited"

Upvotes: 0

Views: 48

Answers (2)

Abhishek Saha
Abhishek Saha

Reputation: 2564

Use this.

CREATE TABLE `invited` (
  `id` int(10) NOT NULL AUTO_INCREMENT,
  `name` varchar(255) NOT NULL,
  `email` varchar(255) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

Upvotes: 1

juergen d
juergen d

Reputation: 204746

You forgot the ID data type

CREATE TABLE invited 
(
    id INT NOT NULL AUTO_INCREMENT, ...
        ^--------------------------------------here

Upvotes: 4

Related Questions