Guest User

Untitled

a guest
Feb 16th, 2018
244
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.31 KB | None | 0 0
  1. <?php
  2.  
  3. function getConnection(){
  4.  
  5. $dsn = 'mysql:host=localhost;dbname=mercadophp';
  6. $user = 'root';
  7. $pass = '';
  8.  
  9. try {
  10.  
  11. $pdo = new PDO ($dsn,$user,$pass, array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8"));
  12.  
  13. return $pdo;
  14.  
  15. } catch (PDOException $ex) {
  16.  
  17. echo "Erro: ".$ex->getMessage();
  18.  
  19. }
  20.  
  21.  
  22. }
Add Comment
Please, Sign In to add comment