创建数据表错误: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')ENGINE=InnoDB DEFAULT CHARSET=utf8' at line 7
changrui
changrui 2020-02-18 22:31:14
0
1
1648

// 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"; ?>

changrui
changrui

reply all (1)
城乡结合部部长

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 ";

    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template
    About us Disclaimer Sitemap
    php.cn:Public welfare online PHP training,Help PHP learners grow quickly!