一、案例演示:
二、php 代码
<?php
$servername = "localhost"; // MySQL服务器名称或IP地址
$username = "root"; // MySQL用户名
$password = "123456"; // MySQL密码
$dbname = "test"; // 要连接的数据库名称
$port = "3307"; // 要连接的数据库名称
// 创建连接
$dbc = new mysqli($servername, $username, $password, $dbname, $port);
// 检查连接是否成功
if ($dbc->connect_error) {
die("连接失败: " . $dbc->connect_error);
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title