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');