Advertisement
Guest User

Untitled

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