//In this PHP DATA OBJECT (PDO) CONNECTION I am gonna use
//the exception code that will help hide your database login
//details from your users if there is an exception (error).
//dbname(database name)
//charset(characters encoding )
try {
$pdo = new PDO('mysql:host=localhost;dbname=joke;charset=utf8','username','password');
$pdo->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION);
echo 'Successfully Connected to the database';
} catch (PDOException $e) {
echo 'ErrorException'.$e->getMessage().'in'.$e->getFile().$e->getCode().$e->getLine();
}