MySQLi表没有制作,但其他人

时间:2014-01-30 06:44:49

标签: php mysql sql mysqli

正在制作此表

$tbl_entertour = "CREATE TABLE IF NOT EXISTS entertour (
                 team_id VARCHAR (16) NOT NULL,
                 tournament_id VARCHAR (16) NOT NULL,
                 provname_id VARCHAR (16) NOT NULL,
                 username VARCHAR (16) NOT NULL,
                 p_1_id VARCHAR (16) NOT NULL,
                 p_2_id VARCHAR (16) NOT NULL,
                 p_3_id VARCHAR (16) NOT NULL,
                 p_4_id VARCHAR (16) NOT NULL,
                 p_5_id VARCHAR (16) NOT NULL,
                 p_6_id VARCHAR (16) NOT NULL,
                 ip VARCHAR (255) NOT NULL,
                 entered DATETIME NOT NULL,
                 UNIQUE KEY username (username)
            )";
$query = mysqli_query($db_conx, $tbl_entertour);    
if ($query === TRUE) {
    echo "<h3>entertour table created OK :) </h3>";
} else {
    echo "<h3>entertour table NOT created :( </h3>";
}

此表尚未制作

$tbl_provtour = "CREATE TABLE IF NOT EXISTS provtour (
                 id INT (11) NOT NULL AUTO_INCREMENT,
                 user_id VARCHAR (16) NOT NULL,
                 provname_id (16) NOT NULL,
                 tourname VARCHAR (25) NOT NULL,
                 team_total ENUM('0','999999') NOT NULL DEFAULT '0',
                 entered_teaams ENUM('0','999999') NOT NULL DEFAULT '0',
                 game VARCHAR (25) NOT NULL,
                 c_1 VARCHAR (25) NOT NULL,
                 c_2 VARCHAR (25) NOT NULL,
                 c_3 VARCHAR (25) NOT NULL,
                 c_open ('0','1') NOT NULL DEFAULT '0',
                 joinopen ('0','1') NOT NULL DEFAULT '0',
                 ip VARCHAR (255) NOT NULL,
                 reg_start DATETIME NOT NULL,
                 reg_end DATETIME NOT NULL,
                 created DATETIME NOT NULL,
                 lastupdated DATETIME NOT NULL,
                 PRIMARY KEY (id),
                 UNIQUE KEY username (user_id)
            )";
$query = mysqli_query($db_conx, $tbl_provtour); 
if ($query === TRUE) {
    echo "<h3>provtour table created OK :) </h3>";
} else {
    echo "<h3>provtour table NOT created :( </h3>";
}

好的我正在尝试在我的数据库中创建第二个表,它似乎没有被制作并返回第二个回声。顶层表格与所有其他表格相同,但由于某种原因,这个底部表格没有。

我不确定为什么。我现在已经看了大约10分钟,我似乎无法找到错误。

由于

1 个答案:

答案 0 :(得分:1)

查询中的错误很少

CREATE TABLE IF NOT EXISTS provtour (
 id INT (11) NOT NULL AUTO_INCREMENT,
 user_id VARCHAR (16) NOT NULL,
 provname_id (16) NOT NULL,
 tourname VARCHAR (25) NOT NULL,
 team_total ENUM('0','999999') NOT NULL DEFAULT '0',
 entered_teaams ENUM('0','999999') NOT NULL DEFAULT '0',
 game VARCHAR (25) NOT NULL,
 c_1 VARCHAR (25) NOT NULL,
 c_2 VARCHAR (25) NOT NULL,
 c_3 VARCHAR (25) NOT NULL,
 c_open ('0','1') NOT NULL DEFAULT '0',
 joinopen ('0','1') NOT NULL DEFAULT '0',
 ip VARCHAR (255) NOT NULL,
 reg_start DATETIME NOT NULL,
 reg_end DATETIME NOT NULL,
 created DATETIME NOT NULL,
 lastupdated DATETIME NOT NULL,
 PRIMARY KEY (id),
 UNIQUE KEY username (user_id)
)
  • provname_id(16)NOT NULL,缺少数据类型
  • c_open('0','1')NOT NULL DEFAULT'0',缺少数据类型
  • joinopen('0','1')NOT NULL DEFAULT'0',缺少数据类型

所以你需要提供一个数据类型

可能是

CREATE TABLE IF NOT EXISTS provtour (
id INT (11) NOT NULL AUTO_INCREMENT,
user_id VARCHAR (16) NOT NULL,
provname_id VARCHAR(16) NOT NULL,
tourname VARCHAR (25) NOT NULL,
team_total ENUM('0','999999') NOT NULL DEFAULT '0',
entered_teaams ENUM('0','999999') NOT NULL DEFAULT '0',
game VARCHAR (25) NOT NULL,
c_1 VARCHAR (25) NOT NULL,
c_2 VARCHAR (25) NOT NULL,
c_3 VARCHAR (25) NOT NULL,
c_open ENUM('0','1') NOT NULL DEFAULT '0',
joinopen ENUM('0','1') NOT NULL DEFAULT '0',
ip VARCHAR (255) NOT NULL,
reg_start DATETIME NOT NULL,
reg_end DATETIME NOT NULL,
created DATETIME NOT NULL,
lastupdated DATETIME NOT NULL,
PRIMARY KEY (id),
UNIQUE KEY username (user_id)
);

在上面的查询中根据需要更改数据类型,我为那些缺少的类型添加了varchar和ENUM。