我正在开发一个在数据库中创建表的安装脚本,在我编写的脚本中,它检测表是否已创建,是否已存在并且根本无法创建表。但由于某种原因,我似乎无法让它发挥作用,任何人都可以帮助我吗?
/* Database Queries */
$dbusers = mysqli_query($con, 'CREATE TABLE users (ID int(9) NOT NULL AUTO_INCREMENT PRIMARY KEY, username VARCHAR(40) NOT NULL, password VARCHAR(40) NOT NULL');
/* Check if Users table was created */
if ($dbusers) {
?>
<p>Table "Users" was successfully created.</p>
<?php
} elseif (mysqli_query($con, "SELECT * FROM users")) {
?>
<p>Table "Users" Already Exists."</p>
<?php
} else {
?>
<p>Unable to create "Users" Table.</p>
<?php
}
那么有没有人对如何改进或修复我的代码有任何想法?
答案 0 :(得分:0)
create
陈述结束时你错过了结束时间:
CREATE TABLE users (ID int(9) NOT NULL AUTO_INCREMENT PRIMARY KEY, username VARCHAR(40) NOT NULL, password VARCHAR(40) NOT NULL)