我需要使用php创建表而不使用phpmyadmin但是第二个块正在执行Table user wasn't created
问题可以通过语句CREATE TABLE....
连接到数据库成功。谢谢你的帮助
if ( (mysqli_query( $mysqli_connect, "CREATE TABLE IF NOT EXISTS user" .
"(user_id int(11) NOT NULL AUTO_INCREMENT,
user_name varchar(64) NOT NULL,
user_password_hash varchar(255)NOT NULL,
user_email varchar(64) NOT NULL,
user_active_status BIT(1) NOT NULL DEFAULT '0' COMMENT 'BIT -bytes representation',
user_activation_hash varchar(40) DEFAULT NULL,
user_password_reset_hash varchar(40) DEFAULT NULL,
user_password_reset_timestamp BIT(20) DEFAULT NULL,
user_rememberme_token varchar(64) DEFAULT NULL,
user_failed_logins BIT(1) NOT NULL DEFAULT '0',
user_last_failed_login int(10) DEFAULT NULL,
user_registration_datetime datetime NOT NULL DEFAULT '0000-00-00 00:00:00' COMMENT 'YYYY-MM-DD HH-MM-SS',
user_registration_ip varchar(39) NOT NULL DEFAULT '0.0.0.0',
PRIMARY KEY(user_id),
UNIQUE KEY user_name (user_name),
UNIQUE KEY user_mail (user_emai)
)ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COMMENT='wordpress uses InnoDB)" ) ) ) {
echo "Table useer was created";
} else {
echo "Table user wasn't created";
}
答案 0 :(得分:1)
您应该看到使用mysqli_error()
我在phpmyadmin
中运行此问题时出现了一些问题(email
拼写错误,评论缺少引号)
下一个查询有效
CREATE TABLE IF NOT EXISTS user (user_id int(11) NOT NULL AUTO_INCREMENT,
user_name varchar(64) NOT NULL,
user_password_hash varchar(255)NOT NULL,
user_email varchar(64) NOT NULL,
user_active_status BIT(1) NOT NULL DEFAULT 0 COMMENT 'BIT -bytes representation',
user_activation_hash varchar(40) DEFAULT NULL,
user_password_reset_hash varchar(40) DEFAULT NULL,
user_password_reset_timestamp BIT(20) DEFAULT NULL,
user_rememberme_token varchar(64) DEFAULT NULL,
user_failed_logins BIT(1) NOT NULL DEFAULT 0,
user_last_failed_login int(10) DEFAULT NULL,
user_registration_datetime datetime NOT NULL DEFAULT '0000-00-00 00:00:00' COMMENT 'YYYY-MM-DD HH-MM-SS',
user_registration_ip varchar(39) NOT NULL DEFAULT '0.0.0.0',
PRIMARY KEY(user_id),
UNIQUE KEY user_name (user_name),
UNIQUE KEY user_mail (user_email)
)ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COMMENT='wordpress uses InnoDB'