Initial commit: WebGIS Kemiskinan Pontianak
This commit is contained in:
+24
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
function loadEnv($path) {
|
||||
if (!file_exists($path)) return;
|
||||
$lines = file($path, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
|
||||
foreach ($lines as $line) {
|
||||
if (strpos(trim($line), '#') === 0) continue;
|
||||
$parts = explode('=', $line, 2);
|
||||
if (count($parts) === 2) {
|
||||
$_ENV[trim($parts[0])] = trim($parts[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
loadEnv(__DIR__ . '/.env');
|
||||
|
||||
$host = $_ENV['DB_HOST'] ?? 'localhost';
|
||||
$user = $_ENV['DB_USER'] ?? 'root';
|
||||
$pass = $_ENV['DB_PASS'] ?? '';
|
||||
$db = $_ENV['DB_NAME'] ?? 'webgis_pontianak';
|
||||
|
||||
$conn = mysqli_connect($host, $user, $pass, $db);
|
||||
if (!$conn) {
|
||||
die('Koneksi gagal: ' . mysqli_connect_error());
|
||||
}
|
||||
Reference in New Issue
Block a user