d
Amit DhamuSoftware Engineer
 

PDO Database Connection

1 minute read 00000 views
function connect($host, $db, $user, $pass) {
    try {
        return new PDO("mysql:host=$host;dbname=$db", $user, $pass);
    } catch (PDOException $e) {
        return $e->getMessage();
    }
}

$connection = connect('localhost', 'database1', 'username', 'password');