Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class DBConnect {
- public function connect() {
- // credentials
- $host = "host";
- $database = "database";
- $username = "username";
- $password = 'password';
- $charset = 'utf8mb4';
- // connection and error handling
- try {
- $dbc = new PDO("mysql:host=$host; dbname=$database; charset=$charset", $username, $password);
- } catch( PDOException $error ) {
- die("ERROR: " . $error->getMessage());
- }
- }
- }
- require "php/dbc.php";
- $dbc = new DBConnect();
- $dbc->connect();
Add Comment
Please, Sign In to add comment