-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdb.php
More file actions
24 lines (20 loc) · 647 Bytes
/
Copy pathdb.php
File metadata and controls
24 lines (20 loc) · 647 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<?php
require_once "config.php";
function konek_db() {
global $DB;
// buka koneksi ke database -- menggunakan mysqli
// parameter 1, nama host database server
// parameter 2, user koneksi
// parameter 3, password koneksi
$conn = mysqli_connect($DB['host'], $DB['user'], $DB['password']);
if (! $conn)
die("<p>Koneksi database gagal.</p>");
// buka database yang akan dioperasikan
// parameter 1, object koneksi
// parameter 2, nama database yang akan dibuka
$db = mysqli_select_db($conn, $DB['db']);
if (! $db)
die("<p>Tidak dapat membuka database.</p>");
return $conn;
}
?>