Guest User

Untitled

a guest
Jun 8th, 2018
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. <?php
  2. $servername = '127.0.0.1';
  3. $username = 'dbuser';
  4. $password = 'dbpassword';
  5. $dbname = 'dbname';
  6.  
  7. // Create connection
  8. $conn = new mysqli($servername, $username, $password);
  9.  
  10. // Check connection
  11. if ($conn->connect_error) {
  12. die("Connection failed: " . $conn->connect_error);
  13. }
  14. echo "Connected successfully";
  15.  
  16. echo "\nTest PDO\n";
  17. try {
  18. $conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password);
  19. // set the PDO error mode to exception
  20. $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  21. echo "PDO Connected successfully";
  22. } catch(PDOException $e) {
  23. echo "PDO Connection failed: " . $e->getMessage();
  24. }
Add Comment
Please, Sign In to add comment