连接PSQL和PHP的页面

问题描述 投票:2回答:1

pgconnect.php

<?php

    $db_connection = pg_connect("host=localhost dbname=postgres user=postgres password=postgres");

    if ($db_connection) {   

    echo 'Connection attempt succeeded.';   

    } else {   

    echo 'Connection attempt failed.';   

    }   
?>

这是我的pgconnect.php页面。我收到内部服务器500错误。我无法弄清楚这段代码的问题。如果有人可以帮助我,那就太好了。

php postgresql
1个回答
0
投票

您可以添加一些代码来显示错误(如果有):

$db_connection = pg_connect("
    host=localhost 
    dbname=postgres 
    user=postgres 
    password=postgres
") or die('Could not connect:' . pg_last_error());
© www.soinside.com 2019 - 2024. All rights reserved.