pastebin

mysql_connect
  1. <?php
  2. class DB
  3. {
  4.  
  5.     private $koneksi;                //Menyimpan koneksi database MySQL
  6.     private $host = "localhost";        //Host database MySQL
  7.     private $user = "root";              //User name database MySQL
  8.     private $password = "";          //Password database MySQL
  9.     private $database = "namadatabase";   //Menyimpan database yang digunakan
  10.  
  11.  
  12.     function DB()
  13.     {
  14.         //Koneksi ke database MySQL
  15.         $this->koneksi=mysql_connect($this->host,$this->user,$this->password) or die ('Error : '.mysql_error().'
  16.        (Koneksi ke database MySQL gagal)');
  17.         mysql_select_db($this->database,$this->koneksi) or die ('Error: '.mysql_error().' (Database yang dipilih tidak ada)');
  18.     }
  19. }
  20.  
  21.  
  22. ?>
Parsed in 0.018 seconds