Guest User

Untitled

a guest
Jul 13th, 2018
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.72 KB | None | 0 0
  1. <?php
  2. ////////////////////////////////////////////////////////////////
  3. //
  4. //  Warning: Editing the following without instruction or
  5. //  knowledge of how it works may lead to errors in its
  6. //  execution, always consult me before editing any of this
  7. //
  8. //  ~David A Perez
  9. // 
  10. ////////////////////////////////////////////////////////////////
  11. // Retrieve DB connection information
  12. require_once'mysql_config.php';
  13.    
  14. class mysql_lib{
  15.     protected $dbhost;
  16.     protected $dbusername;
  17.     protected $dbpassword;
  18.     protected $dbname;
  19.     public $connect;
  20.    
  21.  
  22.     ////////////////////////////////////////////////////////////////
  23.     //  Built it
  24.     ////////////////////////////////////////////////////////////////
  25.     public function __construct(){
  26.         global $db_host;
  27.         global $db_username;
  28.         global $db_password;
  29.         global $db_dbname;
  30.        
  31.         $this->dbhost = $db_host;
  32.         $this->dbusername = $db_username;
  33.         $this->dbpassword = $db_password;
  34.         $this->dbname = $db_dbname;
  35.     }
  36.  
  37.     /////////////////////////////////////////////////////////////////////////////////
  38.     // MySQL Methods
  39.     /////////////////////////////////////////////////////////////////////////////////
  40.    
  41.    
  42.     ////////////////////////////////////////////////////////////////
  43.     //  Open connection
  44.     ////////////////////////////////////////////////////////////////   
  45.     public function open_connect(){
  46.         $this->connect = mysql_connect($this->dbhost,$this->dbusername,$this->dbpassword);
  47.        
  48.         if(!$this->connect){
  49.             die('Error connecting to MySQL: '.mysql_error());
  50.         }  
  51.         mysql_select_db($this->dbname,$this->connect);
  52.     }
  53.    
  54.     ////////////////////////////////////////////////////////////////
  55.     //  Close Connection
  56.     ////////////////////////////////////////////////////////////////
  57.     public function close_connect(){
  58.         mysql_close($this->connect);
  59.     }
  60. }
  61.  
  62. ?>
Add Comment
Please, Sign In to add comment