Guest User

dbbbb

a guest
Oct 17th, 2016
28
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. <?php
  2. $db = isset($_POST['db']) ? $_POST['db'] : '';
  3. class Database
  4. {
  5.  
  6. private $host = "localhost";
  7. private $db_name = "designer3";
  8. private $username = "root";
  9. private $password = "54545";
  10. public $conn;
  11.  
  12. public function dbConnection()
  13.  
  14. {
  15. global $pdo;
  16. $db = isset($_POST['db']) ? $_POST['db'] : '';
  17. $this->conn = null;
  18. try
  19. {
  20.  
  21. $this->conn = new PDO("mysql:host=" . $this->host . ";dbname=" . $this->db_name, $this->username, $this->password);
  22. $this->conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  23. }
  24. catch(PDOException $exception)
  25. {
  26. echo "Connection error: " . $exception->getMessage();
  27. }
  28.  
  29. return $this->conn;
  30. }
  31. }
  32. ?>
Add Comment
Please, Sign In to add comment