Advertisement
Guest User

Untitled

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