Thread: PHP and Postgresql on Windows

PHP and Postgresql on Windows

From
typing80wpm@aol.com
Date:
I searched on goolge and found my answer, I think.
 
From what I see (below), all I need to do is a WAMP install from one of the CDs in the back of the PHP books I bought, and then un-comment the extension=php_pgsql.dll
 
 
 
 
Connect to PostgreSQL from PHP
Open your php.ini file (most likely located in c:\winnt), find the section called Dynamic Extensions and un-comment the line that contains "extension=php_pgsql.dll". Save and close php.ini and restart Apache. If the Web server complains and says it's unable to load the dynamic library, you probably have entered the wrong path for extension_dir in php.ini (section Paths and Directories). Another possible -– though unlikely -- cause is that the file php_pgsql.dll isn't present in the extensions directory.
 
Now you should be able to run the following little PHP script:
 
<?
$conn = pg_connect("host=localhost 
   port=5432 
   dbname=template1 
   user=postgres 
   password=********");
$sql = "SELECT current_date AS today;";
$result = pg_query($conn, $sql);
$row = pg_fetch_object($result, 0);
echo "Today is: " .$row->today;
?>
 
 
The script isn't too exciting, but at least it shows you how to connect to the database and execute a query.