-5
$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)
);");

有谁知道为什么它不起作用?

提前致谢

4

4 回答 4

4

您只能将列定义AUTO_INCREMENTPRIMARY KEY.

因此,只需将 a 添加PRIMARY KEYAUTO 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)
);
于 2013-09-29T08:41:06.720 回答
0
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)
);
于 2013-09-29T08:43:07.133 回答
0
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,
于 2013-09-29T08:44:02.080 回答
0

是的,我也没有收到任何错误

虽然你应该.

mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);

在您的代码中加入这一行,您将立即知道问题所在,并在不浪费社区力量的情况下解决它。

于 2013-09-29T08:58:57.367 回答