$con->query("CREATE TABLE jobs
(
ID INT AUTO_INCREMENT,
Title VARCHAR(32),
Company VARCHAR(32),
Country VARCHAR(32),
City VARCHAR(32),
Email VARCHAR(32),
Website VARCHAR(32),
Description VARCHAR(1000)
);");
有谁知道为什么它不起作用?
提前致谢
您只能将列定义AUTO_INCREMENT
为PRIMARY KEY
.
因此,只需将 a 添加PRIMARY KEY
到AUTO INCREMENT
列中,如下所示:
CREATE TABLE jobs
(
ID INT AUTO_INCREMENT,
Title VARCHAR(32),
Company VARCHAR(32),
Country VARCHAR(32),
City VARCHAR(32),
Email VARCHAR(32),
Website VARCHAR(32),
Description VARCHAR(1000),
PRIMARY KEY (ID)
);
Because there was no primary key defined,try this
CREATE TABLE jobs
(
ID INT AUTO_INCREMENT PRIMARY KEY,
Title VARCHAR(32),
Company VARCHAR(32),
Country VARCHAR(32),
City VARCHAR(32),
Email VARCHAR(32),
Website VARCHAR(32),
Description VARCHAR(1000)
);
Incorrect table definition;
there can be only one auto column and it must be defined as a key
将主密钥添加到 ID
ID INT AUTO_INCREMENT PRIMARY KEY,
是的,我也没有收到任何错误
虽然你应该.
mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
在您的代码中加入这一行,您将立即知道问题所在,并在不浪费社区力量的情况下解决它。