I am trying to add dynamic interactions with my PostgreSQL 12 database to my web page with the PostGIS extension that I use with PgAdmin 4. I use an Apache web server that I installed with MS4W. For dynamics, I chose the PHP language. I managed to configure it to show my errors, but I cannot configure the pgsql extensions to use "pg_connect ()" type functions.
<?php
$dbconn = pg_connect("host=localhost dbname=xxxx user=xxxx password=xxxx")
or die('Connexion impossible : ' . pg_last_error());
$query = 'SELECT * FROM signaletique';
$result = pg_query($query) or die('Échec de la requête : ' . pg_last_error());
echo "<table>\n";
while ($line = pg_fetch_array($result, null, PGSQL_BOTH)) {
echo "\t<tr>\n";
foreach ($line as $col_value) {
echo "\t\t<td>$col_value</td>\n";
}
echo "\t</tr>\n";
}
echo "</table>\n";
pg_free_result($result);
pg_close($dbconn);
But the page returns me:
Fatal error: Uncaught Error: Call to undefined function pg_connect() in C:\ms4w\Apache\htdocs\test.php:4 Stack trace: #0 {main} thrown in C:\ms4w\Apache\htdocs\test.php on line 4
I tested the connection between php and the extension
<?php
echo extension_loaded('pgsql') ? 'yes':'no';
?>
And the page return "no".
So I went to php.ini to configure the extensions and remove the ";".
And in httpd.conf I added the following line to this position:
I tried the echo "extension_loaded" again but it doesn't work.
So I respected what was written on the different answers from orum and on the php website, but it still doesn't work. I know my code is not orthodox, but it is a test code given by php.net It's been several weeks that I try different languages, and that I search for script and I currently have all the material to work well in php and finish my project but I have to manage to make it work.