简体   繁体   中英

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

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).

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM