diff --git a/get_vip_customer.php b/get_vip_customer.php index 0dd71be..9b27ad4 100644 --- a/get_vip_customer.php +++ b/get_vip_customer.php @@ -11,11 +11,21 @@ if (!$id) { exit; } -// 数据库连接配置 -$host = 'localhost'; -$dbname = 'carwash_booking'; -$username = 'root'; -$password = ''; +// 引入根目录的数据库配置文件 +require_once __DIR__ . '/config.php'; + +// 确保配置变量存在 +if (!isset($host) || !isset($username) || !isset($password) || !isset($database)) { + http_response_code(500); + echo json_encode([ + 'error' => '配置文件加载失败', + 'message' => '无法读取数据库配置信息' + ], JSON_UNESCAPED_UNICODE); + exit; +} + +// 配置变量重命名,确保兼容性 +$dbname = $database; try { $pdo = new PDO("mysql:host=$host;dbname=$dbname;charset=utf8mb4", $username, $password);