Advertisement
Guest User

Erik2

a guest
Dec 6th, 2016
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.40 KB | None | 0 0
  1. $servername = "localhost";
  2. $username = "root";
  3. $password = "";
  4.  
  5. try {
  6.     $conn = new PDO("mysql:host=$servername;dbname=php_contact", $username, $password);
  7.     // set the PDO error mode to exception
  8.     $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  9.     // echo "Connected successfully \n";
  10.     }
  11. catch(PDOException $e)
  12.     {
  13.     echo "Connection failed: " . $e->getMessage();
  14.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement