SHARE
TWEET

Untitled

a guest Oct 3rd, 2017 64 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. class Database {
  3.     public $hostname;
  4.     public $username;
  5.     public $password;
  6.     public $database;
  7.     public $dblink;
  8.    
  9.     public function connect() {
  10.         $this->dblink = mysql_connect($this->hostname,$this->username,$this->password) or die("Could not connect. ");
  11.         mysql_select_db($this->database, $this->dblink) or die("Could not select database.");
  12.     }
  13. }
  14.  
  15. $db = new Database();
  16.  
  17. $db->hostname = 'localhost';
  18. $db->username = 'root';
  19. $db->password = '1234';
  20. $db->database = 'blog';
  21. $db->connect();
  22.  
  23. if ($db->connect()) {
  24.     print("Connected to $db->hostname!");
  25. }
  26.  
  27. else {
  28.     print("Not connected to $db->hostname!");
  29. }
  30.  
  31. ?>
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