<?php try { $dbh = new PDO('pgsql:host=localhost;port=5432;dbname=###;user=###;password=##'); echo "PDO connection object created"; } catch(PDOException $e) { echo $e->getMessage(); } ?>
I get the error message "Could Not Load Driver"
Connecting to Database php $host = "host = 127.0. 0.1"; $port = "port = 5432"; $dbname = "dbname = testdb"; $credentials = "user = postgres password=pass123"; $db = pg_connect( "$host $port $dbname $credentials" ); if(!
PostgreSQL Functions (PDO_PGSQL) ¶PDO_PGSQL is a driver that implements the PHP Data Objects (PDO) interface to enable access from PHP to PostgreSQL databases.
pg_connect() opens a connection to a PostgreSQL database specified by the connection_string .
You need to install the pgsql module for php. In debian/ubuntu is something like this:
sudo apt-get install php5-pgsql
Or if the package is installed, you need to enable de module in php.ini
extension=php_pgsql.dll (windows) extension=php_pgsql.so (linux)
Greatings.
Try this:
Uncomment the following in php.ini by removing the ";"
;extension=php_pgsql.dll
Use the following code to connect to a postgresql database server:
pg_connect("host=localhost dbname=dbname user=username password=password") or die("Can't connect to database".pg_last_error());
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With