?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);
?>