Guest User

Untitled

a guest
May 14th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. <?php
  2.  
  3. include('config.php');
  4.  
  5. class Connect{
  6.  
  7. private $host;
  8. private $admin;
  9. private $pass;
  10. private $db;
  11. private $link;
  12. function __construct() {
  13. $this->host = $db_host;
  14. $this->user = $db_user;
  15. $this->pass = $db_pass;
  16. $this->db = $db_database;
  17. $this->connectDB();
  18. echo $this->host;
  19. }
  20.  
  21. function __destruct() {
  22. $this->closeDB();
  23. }
  24.  
  25. private function connectDB(){
  26. $this->link = mysql_connect($this->host,$this->user,$this->pass) or die('Unable to establish a DB connection');
  27. mysql_select_db($this->db,$this->link);
  28. }
  29.  
  30. public function query($query){
  31. if(!$this->link){
  32. $this->connectDB();
  33. }
  34.  
  35. $this->result = mysql_query($query) or die(mysql_error());
  36. return $this->result;
  37.  
  38. }
  39.  
  40. private function closeDB(){
  41.  
  42. return mysql_close();
  43.  
  44. }
  45. }
  46.  
  47.  
  48. ?>
Add Comment
Please, Sign In to add comment