Advertisement
Guest User

Untitled

a guest
Jan 15th, 2018
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.73 KB | None | 0 0
  1. <?php
  2.  
  3.   class dbConnect {
  4.  
  5.     private $username = "root";
  6.     private $password = "";
  7.  
  8.     public function __construct($username, $password) {
  9.       $this->username = $username;
  10.       $this->password = $password;
  11.     }
  12.  
  13.     public function connect($username, $password) {
  14.       $conn = new PDO('mysql:host=localhost;dbname=sequencemtg', $username, $password);
  15.       if (!$conn) {
  16.         die("Connection failed: " . $conn->connect_error);
  17.       } else {
  18.         print "It worked!";
  19.       }
  20.     }
  21.  
  22.   }
  23.  
  24.   $username = "root";
  25.   $password = "";
  26.   $conn = new PDO('mysql:host=localhost;dbname=sequencemtg', $username, $password);
  27.   $test = new dbConnect($username, $password);
  28.   $test->connect($username, $password);
  29.  
  30. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement