Advertisement
Guest User

Untitled

a guest
Mar 12th, 2017
110
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. $servername = "localhost";
  3. $username = "";
  4. $password = "";
  5.  
  6.  
  7. try {
  8.     $conn = new PDO("mysql:host=$servername;dbname=", $username, $password);
  9.     // set the PDO error mode to exception
  10.     $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  11.     echo "Connected successfully";
  12.     }
  13. catch(PDOException $e)
  14.     {
  15.     echo "Connection failed: " . $e->getMessage();
  16.     }
  17. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement