?php
// 假定数据库用户名:root,密码:123456,数据库:codingdict
$con=mysqli_connect("localhost","root","123456","codingdict");
if (mysqli_connect_errno($con))
{
echo "连接 MySQL 失败: " . mysqli_connect_error();
}
// 数据表 websites 已存在,所以返回错误
$sql="CREATE TABLE websites (name VARCHAR(30),url VARCHAR(30),alexa INT)";
if (!mysqli_query($con,$sql))
{
echo "SQLSTATE error: ". mysqli_sqlstate($con);
}
// 关闭连接
mysqli_close($con);
?>