使用PHP编写脚本测试数据库连接是否正常

by Web全栈工程师 on 2014 年 12 月 21 日



$host = '127.0.0.1';
$user = '';
$pass = '';
$db   = '';

$conn = mysqli_connect($host, $user, $pass, $db);

if (!$conn) {
    die("连接失败: " . mysqli_connect_error());
}
echo "数据库连接成功!";

Comments on this entry are closed.

Previous post:

Next post: