我已使用这些代码在本地服务器上连接和创建表:
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "newone";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
// sql to create table
$sql = "CREATE TABLE newlogin (
id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
firstname VARCHAR(30) NOT NULL,
lastname VARCHAR(30) NOT NULL,
email VARCHAR(50),
reg_date TIMESTAMP
)";
if ($conn->query($sql) === TRUE) {
echo "Table newlogin created successfully";
} else {
echo "Error creating table: " . $conn->error;
}
$conn->close();
?>
显示此错误:
connect_error){die(&#34;连接失败:&#34;。$ conn-&gt; connect_error); } // sql创建表$ sql =&#34; CREATE TABLE newlogin(id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY,firstname VARCHAR(30)NOT NULL, lastname VARCHAR(30)NOT NULL,电子邮件VARCHAR(50),reg_date TIMESTAMP )&#34 ;; if($ conn-&gt; query($ sql)=== TRUE){echo&#34;表newlogin created created 成功&#34 ;; } else {echo&#34;创建表时出错:&#34; 。 $ conn-&GT;误差; } $ conn-&gt; close(); ?&GT;
请回答我是什么问题?我正在使用xampp作为我的本地主机服务器。
谢谢