Guest User

Untitled

a guest
Dec 16th, 2018
266
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.80 KB | None | 0 0
  1. <?php
  2.  
  3.  
  4. class Database {
  5.    
  6.     public $hostname;
  7.     public $username;
  8.     public $password;
  9.     public $database;
  10.    
  11.     public function Connect($hostname, $username, $password, $database) {
  12.        
  13.         $this->hostname = $hostname;
  14.         $this->username = $username;
  15.         $this->password = $password;
  16.         $this->database = $database;
  17.        
  18.         mysql_connect($this->hostname, $this->username, $this->password);
  19.         mysql_select_db($this->database);
  20.        
  21.     }
  22.    
  23.     public function Query($sql) {
  24.        
  25.         return mysql_query($sql);
  26.         $this->Close();
  27.        
  28.        
  29.        
  30.     }
  31.    
  32.     public function Close() {
  33.        
  34.         mysql_close();
  35.        
  36.     }
  37.    
  38.    
  39.    
  40. }
  41.  
  42. //Maybe works?
  43.  
  44. $Database = new Database();
  45.  
  46. $Database->Connect("localhost","username","password","database");
  47.  
  48. $Database->Query("select key from serials where owner='rolloadam'");
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56. ?>
Add Comment
Please, Sign In to add comment