Advertisement
Guest User

Untitled

a guest
Jan 13th, 2016
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. $host='localhost';
  2. $db = 'bd';
  3. $username = 'postgres';
  4. $password = 'admin';
  5.  
  6. $dsn = "pgsql:host=$host;port=5432;dbname=$db;user=$username;password=$password";
  7.  
  8. try{
  9. // create a PostgreSQL database connection
  10. $conn = new PDO($dsn);
  11.  
  12. // display a message if connected to the PostgreSQL successfully
  13. if($conn){
  14. echo "Connected to the <strong>$db</strong> database successfully!";
  15. }
  16. }catch (PDOException $e){
  17. // report error message
  18. echo $e->getMessage();
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement