Bicas

Untitled

Dec 20th, 2014
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.44 KB | None | 0 0
  1. <?php
  2.     function dbConnect()
  3.     {
  4.         try
  5.         {
  6.             $username = 'root';
  7.             $password = '';
  8.             $conn = new pdo("mysql:host=localhost;dbname=serveris;", $username, $password);
  9.             $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  10.             return $conn;
  11.  
  12.         }  
  13.  
  14.         catch(PDOException $e)
  15.         {
  16.             echo 'ERROR', $e->getMessage();
  17.         }
  18.     }
  19. ?>
Advertisement
Add Comment
Please, Sign In to add comment