Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $db = isset($_POST['db']) ? $_POST['db'] : '';
- class Database
- {
- private $host = "localhost";
- private $db_name = "designer6";
- private $username = "root";
- private $password = "123456";
- public $conn;
- public function dbConnection()
- {
- $db = isset($_POST['db']) ? $_POST['db'] : '';
- $this->conn = null;
- try
- {
- $this->conn = new PDO("mysql:host=" . $this->host . ";dbname=" . $this->db_name, $this->username, $this->password);
- $this->conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
- }
- catch(PDOException $exception)
- {
- echo "Connection error: " . $exception->getMessage();
- }
- return $this->conn;
- }
- }
- ?>
Add Comment
Please, Sign In to add comment