<?php
// Create connection
$conn = new mysqli("localhost", "uesename", "password","test");
// Detect connection
if ($conn->connect_error)
{
die("Connection failed: " . $conn->connect_error);
}
// Use sql to create a data table
$ 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 { Table MyGuests created successfully"; ?>
城乡结合部部长2020-02-19 12:36:31
The statement to create the table, there cannot be a comma here at the end, it should be enough to remove it. This is SQL syntax, commas are required at the beginning and not at the end.
created_at datetime NOT NULL
)ENGINE=InnoDB DEFAULT CHARSET=utf8 ";