上传文件至 /
This commit is contained in:
43
config.php
Normal file
43
config.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
// 数据库配置文件
|
||||
// 请根据你的虚拟主机信息填写正确内容
|
||||
|
||||
// 数据库服务器地址
|
||||
$db_host = 'localhost'; // 大多数情况下是localhost,部分主机可能需要特定IP
|
||||
|
||||
// 数据库用户名
|
||||
// 注意:虚拟主机通常使用 "cpanel用户名_数据库用户名" 格式
|
||||
$db_user = 'a1sax1m9i'; // 替换为你的实际数据库用户名
|
||||
|
||||
// 数据库密码
|
||||
$db_pass = 'a1sax1m9i'; // 替换为你的实际数据库密码
|
||||
|
||||
// 数据库名称
|
||||
// 注意:虚拟主机通常使用 "cpanel用户名_数据库名" 格式
|
||||
$db_name = 'a1sax1m9i'; // 替换为你的实际数据库名称
|
||||
|
||||
// 创建数据库连接函数
|
||||
function getDbConnection() {
|
||||
global $db_host, $db_user, $db_pass, $db_name;
|
||||
|
||||
// 创建连接
|
||||
$conn = new mysqli($db_host, $db_user, $db_pass, $db_name);
|
||||
|
||||
// 检查连接
|
||||
if ($conn->connect_error) {
|
||||
// 返回错误信息而非直接终止
|
||||
return [
|
||||
'success' => false,
|
||||
'error' => '连接失败: ' . $conn->connect_error .
|
||||
'<br>服务器: ' . $db_host .
|
||||
'<br>用户名: ' . $db_user .
|
||||
'<br>数据库: ' . $db_name
|
||||
];
|
||||
}
|
||||
|
||||
return [
|
||||
'success' => true,
|
||||
'connection' => $conn
|
||||
];
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user