0
$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"

2
  • 2
    Instead of just die() output the error message using mysqli_error( $dbc )! Commented Nov 15, 2012 at 10:20
  • you dont specified type of id column (e.g. int) Commented Nov 15, 2012 at 10:41

2 Answers 2

4

You forgot the ID data type

CREATE TABLE invited 
(
    id INT NOT NULL AUTO_INCREMENT, ...
        ^--------------------------------------here
Sign up to request clarification or add additional context in comments.

Comments

1

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 ;

1 Comment

You can even have it in this multi-line format so it is easy to read by using a heredoc or a nowdoc.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.