我编写了以下代码,我正在尝试进行安装以创建SQL的数据库和表,但我无法弄清楚它为什么不创建数据库或表。
CONFIG.PHP
<?php
// Database Details
$host = 'localhost';
$user = 'root';
$password = '';
//Install Settings
$root_username = 'root';
$root_password = 'password';
// Install Settings Advanced - Do Not Modify For Default Settings
$database = 'Sims2';
?>
INSTALL.PHP
<?php
include 'config.php';
// Remove any instance of .mysqli_connect_error() before publishing
$conn = mysqli_connect($host,$user,$password);
if (!$conn) {die("Connection failed: ".mysqli_connect_error());};
$sql = "CREATE DATABASE Sims2";
if (!$conn){die("Error creating database: ".mysqli_connect_error());};
$sql = "CREATE TABLE TEACHERS (
id INT(11) NOT NULL PRIMARY KEY AUTO_INCREMENT,
uid VARCHAR(128) NOT NULL,
pwd VARCHAR(128) NOT NULL
);";
if(!$conn){die("Error creating table: ".mysqli_connect_error());};
$sql = "CREATE TABLE STUDENTS (
id INT(11) NOT NULL PRIMARY KEY AUTO_INCREMENT,
first VARCHAR(64) NOT NULL,
last VARCHAR(64) NOT NULL,
gender VARCHAR(6) NOT NULL,
dob VARCHAR(10) NOT NULL,
semail VARCHAR(64) NOT NULL,
address VARCHAR(120) NOT NULL,
phone VARCHAR(15) NOT NULL,
tutor VARCHAR(64) NOT NULL
);";
if(!$conn){die("Error creating table: ".mysqli_connect_error());};
$sql = "INSERT INTO TEACHERS (uid, pwd) VALUES ($root_username,$root_password)";
if(!$conn){die("Error creating root account: ".mysqli_connect_error());};
echo "Done";
?>
任何帮助将不胜感激