<?php
// 创建连接
$conn = new mysqli("localhost", "uesename", "password","test");
// 检测连接
if ($conn->connect_error)
{
die("连接失败: " . $conn->connect_error);
}
// 使用 sql 创建数据表
$sql = "CREATE TABLE new (
id int(10) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
title varchar(100) NOT NULL,
author varchar(20) NOT NULL,
content text NOT NULL,
created_at datetime NOT NULL,
)ENGINE=InnoDB DEFAULT CHARSET=utf8 ";
if ($conn->query($sql) === TRUE)
{
echo "Table MyGuests created successfully";
} else {
echo "创建数据表错误: " . $conn->error;
}
$conn->close();
?>
城乡结合部部长2020-02-19 12:36:31
创建表格的语句,最后这里不能有逗号,去掉应该就可以了。这个是sql语法,前面都需要逗号,最后不需要。
created_at datetime NOT NULL
)ENGINE=InnoDB DEFAULT CHARSET=utf8 ";