Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<?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
You can’t perform that action at this time.