Guest User

Untitled

a guest
Apr 28th, 2018
467
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. $servername = "1.1.1.1";
  2. $username = "username";
  3. $password = "********";
  4.  
  5. try {
  6. $conn = new PDO("mysql:host=$servername;dbname=", $username, $password);
  7. // set the PDO error mode to exception
  8. $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  9. echo "Connected successfully";
  10. }
  11. catch(PDOException $e)
  12. {
  13. echo "Connection failed: " . $e->getMessage();
  14. }
  15.  
  16. Connection failed: SQLSTATE[HY000] [2002] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
Add Comment
Please, Sign In to add comment