<?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