Guest User

Untitled

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