无法连接到postgresql

无法连接到postgresql,postgresql,Postgresql,我已经编写了以下代码 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"> <html> <head></head> <body> <?php // attempt a connection // $conn_string = "host=localhost port=5432 dbname=postgi

我已经编写了以下代码

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html>
    <head></head>
    <body>
        <?php
            // attempt a connection
            // $conn_string = "host=localhost port=5432 dbname=postgis user=postgres password=1234";
            // $dbh = pg_connect($conn_string);  

            $dbh = pg_connect("host=localhost port=5432 dbname=postgis user=postgres password=1234");

            if (!$dbh) {
                die("Error in connection: " . pg_last_error());
            }

            // execute query
            $sql = "SELECT * FROM assets";
            $result = pg_query($dbh, $sql);

            if (!$result) {
                die("Error in SQL query: " . pg_last_error());
            }

            // iterate over result set
            // print each row
            while ($row = pg_fetch_array($result)) {
                echo ": " . $row[0] . "<br />";
                echo ": " . $row[1] . "<p />";
            }

            // free memory
            pg_free_result($result);

            // close connection
            pg_close($dbh);
        ?>
    </body>
</html>

WAMP中没有postgresql server或db

下载具有postgresql server WAPP的本地服务器

您安装了库吗?正如Marco所说,您缺少PHP的ps postgreql插件(库),或者您没有在PHP配置中启用它。请删除PHP.ini中
extension=PHP\u pgsql.dll
行之前的注释,然后重新启动Web服务器questor似乎已手动将postresql添加到他的wamp设置中。我怀疑不涉及抛弃他所拥有的东西的答案会更受欢迎。
Call to undefined function pg_connect() in C:\wamp\www\newphp.php on line 18