fix: update koneksi database menggunakan normal user

This commit is contained in:
2026-06-10 00:22:31 +07:00
parent b64b896960
commit 16177783fd
+15 -6
View File
@@ -1,8 +1,18 @@
<?php <?php
$host = "localhost"; $host_sekarang = $_SERVER['SERVER_NAME'];
$user = "root";
$pass = ""; if ($host_sekarang === 'localhost' || $host_sekarang === '127.0.0.1') {
$db = "webgis_db"; $host = "localhost";
$user = "root";
$pass = "";
$db = "webgis_db";
} else {
// Gunakan Kredensial Normal User dari Coolify
$host = "mysql-webgis";
$user = "mysql"; // Menggunakan Normal User
$pass = "YN54ned6j7P6K7c76sLqh9ERUbm8xvhPFj31Mnt0yKPXxqrIhWICWlbJbJjUCfn7"; // Normal User Password
$db = "default";
}
// Connect to MySQL server first // Connect to MySQL server first
$conn = new mysqli($host, $user, $pass); $conn = new mysqli($host, $user, $pass);
@@ -12,7 +22,7 @@ if ($conn->connect_error) {
} }
// Create database if not exists // Create database if not exists
$conn->query("CREATE DATABASE IF NOT EXISTS `$db` CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;"); // $conn->query("CREATE DATABASE IF NOT EXISTS `$db` CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;");
// Select database // Select database
$conn->select_db($db); $conn->select_db($db);
@@ -45,4 +55,3 @@ if ($row['count'] == 0) {
$stmt->execute(); $stmt->execute();
$stmt->close(); $stmt->close();
} }
?>