Last active
March 8, 2018 00:32
-
-
Save carlosdcordero/1da415533e193256e99dea27f2a2fa2b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function conectar($nameDB = '', $userDB = '', $passDB = '') { | |
if ($nameDB !== ''|| $userDB !== ''|| $passDB !== '') { | |
try { | |
$link = new PDO ( | |
'mysql:host=localhost; | |
dbname=' . $nameDB . '', | |
$userDB, | |
$passDB | |
); | |
} catch (PDOException $e) { | |
print '¡Error!: ' . $e->getMessage() . '<br/>'; | |
die(); | |
} | |
} else { | |
echo '¡Error al conectar!'; | |
} | |
return $link; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment