Dorian_gd
Dorian_gd

Reputation: 181

Mysqli error 1064 CREATE TABLE

This is working:

$req = $mysqli->query("CREATE TABLE IF NOT EXISTS ".$tableprefix."admin (
            ID_ADMIN INT NOT NULL AUTO_INCREMENT,
            login VARCHAR(200) NOT NULL,
            password VARCHAR(200) NOT NULL,
            mail VARCHAR(200) NOT NULL,
            PRIMARY KEY(ID_ADMIN))");

This is not working:

$req2 = $mysqli->query("CREATE TABLE IF NOT EXISTS ".$tableprefix."pages (
            ID_PAGE INT NOT NULL AUTO_INCREMENT,
            title VARCHAR(200) NOT NULL,
            content TEXT,
            order INT NOT NULL,
            status INT NOT NULL,
            PRIMARY KEY(ID_PAGE))");

Anybody can help me? Thank you

Upvotes: 0

Views: 185

Answers (2)

BWS
BWS

Reputation: 3846

You shouldn't name a column in the table "order" ... it's a reserved word. Call it something else, like p_order, or something. It will only get more confusing later on, especially if you ever want to ORDER by it.

Upvotes: 2

jeroen
jeroen

Reputation: 91744

ORDER is a reserved word in mysql so you would need to enclose it in backticks:

`order` INT NOT NULL,

or use a different name (that's what I would do).

Upvotes: 4

Related Questions