Advertisement
Guest User

Tutorial City

a guest
Feb 11th, 2010
4,102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.40 KB | None | 0 0
  1. <?php
  2.  
  3. define('HOST','localhost');
  4. define('DB_NAME','pdo');
  5. define('USER','eduardo');
  6. define('PASS','php_data_objects');
  7.  
  8. $dsn = 'mysql:host='.HOST.';dbname='.DB_NAME;
  9.  
  10. try {
  11.     $bd = new PDO($dsn,USER,PASS); 
  12.     $bd->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION);
  13. } catch (PDOException $e) {
  14.     echo htmlentities('Houve algum erro com a conexão com o banco de dados: '. $e->getMessage());
  15. }
  16.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement