Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $host='localhost';
- $db = 'bd';
- $username = 'postgres';
- $password = 'admin';
- $dsn = "pgsql:host=$host;port=5432;dbname=$db;user=$username;password=$password";
- try{
- // create a PostgreSQL database connection
- $conn = new PDO($dsn);
- // display a message if connected to the PostgreSQL successfully
- if($conn){
- echo "Connected to the <strong>$db</strong> database successfully!";
- }
- }catch (PDOException $e){
- // report error message
- echo $e->getMessage();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement