Skip to content

Instantly share code, notes, and snippets.

@nunomazer
Last active January 13, 2018 19:33
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nunomazer/5453844 to your computer and use it in GitHub Desktop.
Save nunomazer/5453844 to your computer and use it in GitHub Desktop.
<?php
define('DB_DRIVER', 'mysql');
define('DB_HOST', 'localhost');
define('DB_USER', 'root');
define('DB_PWD', 'minhasenha');
define('DB_DATABASE', 'meubancodedados');
try {
$pdo = new PDO(DB_DRIVER.':host='.DB_HOST.';dbname='.DB_DATABASE, DB_USER, DB_PWD);
if ($pdo) {
echo "Conexão realizada com sucesso!";
} else {
echo "Problemas na conexão!";
}
} catch (PDOException $exc) {
echo "Problemas na conexão!";
echo $exc->getMessage().
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment