Advertisement
Guest User

Untitled

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