1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | <?php $servername = "localhost"; //host $database = "library"; //nama database $username = "root"; //username $password = ""; //password jika ada $conn = mysqli_connect($servername, $username, $password, $database); // mengecek koneksi if (!$conn) { die("Koneksi database gagal : " . mysqli_connect_error()); }else{ echo "Koneksi berhasil terhubung ke database"; } ?> |
Kemudian jalankan di browser jika terhubung akan muncul pesan
Gambar 0.1 Tes Koneksi PHP & MYQL
Selamat Mencoba. . . .
0 Komentar