Last active
August 29, 2015 13:58
-
-
Save abdullahalim/10349211 to your computer and use it in GitHub Desktop.
Koneksi ke Database MySQL menggunakan PHP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// deklarasi variable yang akan digunakan | |
$host = "localhost"; | |
$user = "root"; | |
$pass = ""; | |
$database = "db_belajar"; | |
/* | |
* membuat hubungan ke database MySQL dengan menggunakan function mysql_connect() | |
*/ | |
mysql_connect($host,$user,$pass) or die(mysql_error()); | |
/* | |
* mysql_select_db merupakan function PHP yang kita gunakan untuk memilih database | |
* yang ingin kita gunakan, mysql_select_db() di operasikan setelah melakukan koneksi | |
* ke database MySQL | |
*/ | |
mysql_select_db($database) or die(mysql_error()); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment