SHARE
TWEET

Untitled

a guest May 22nd, 2018 111 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. /*
  4.  *
  5.  */
  6.  
  7. /** E-libarry_IT
  8.  *
  9.  * @author Admin
  10.  */
  11. class Database {
  12.    
  13.     private $host;
  14.     private $user;
  15.     private $password;
  16.     private $database;
  17.     public  $conn;
  18.    
  19.    
  20.     function __construct($filename) {
  21.         if(is_file($filename)) include $filename;
  22.         else    throw new Exception("Error!");
  23.        
  24.         $this->host = $host;
  25.         $this->user = $user;
  26.         $this->password = $password;
  27.         $this->database = $database;
  28.        
  29.         $this->connect();
  30.  
  31.  
  32.     }
  33.     private function connect()
  34.     {
  35.         $this->conn = mysql_connect($this->host, $this->user, $this->password)
  36.         //connected to the server .
  37.         if (!$this->conn) {
  38.             throw new Exception("Error: not connected to the server.");
  39.         }
  40.  
  41.         // select the database .
  42.         if(!mysql_select_db($this->conn,$this->database))
  43.             throw new Exception("Error: No database selected");
  44.            
  45.  else
  46.                 echo 'OK';
  47.  
  48.        
  49.     }
  50.    
  51.     function close(){
  52.         mysqli_close();
  53.        
  54.     }
  55.     }
  56.    
  57.      
  58.    
  59.    
  60.     ?>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top