通过PHP连接到PostgreSQL
它只是停留在。。。或者死(“无法连接”);没有其他事情发生,但我知道连接字符串上的一切都是正确的通过PHP连接到PostgreSQL,php,postgresql,Php,Postgresql,它只是停留在。。。或者死(“无法连接”);没有其他事情发生,但我知道连接字符串上的一切都是正确的 <?php header('Content-Type: text/html; charset=utf-8'); echo "Teste Inicio"; //To see if it can reach this part of code $conn_string = "host='localhost' port='5432' dbname='name_db' us
<?php
header('Content-Type: text/html; charset=utf-8');
echo "Teste Inicio"; //To see if it can reach this part of code
$conn_string = "host='localhost' port='5432' dbname='name_db' user='user_pgsql' password='passuser_pgsql'"; //Connection String
$db_conn = pg_connect($conn_string) or die("Can't Connect");
echo "Teste Depois Conexão"; //To see if it can reach this part of code
$stat = pg_connection_status($db_conn);
echo $stat;
if ($db_conn)
{
echo "Teste Conectou"; //Echo to see if it has connected
$query = "SELECT idgestores FROM gestores"; //Query
echo "<br>"."Conexão bem sucedida"; //Connection Successfully
$result = pg_query($db_conn, $query);
while($row = pg_fetch_row($result))
{
echo "<br>"."ID: $row[0] Nome: $row[1]";
echo "<br>";
}
}
else
{
echo "Teste Erro"; //Error
echo "Erro de Ligação"; //Error
}
?>
尝试重新移动dsn上的简单引号($conn\u string
)是否确定用户\u pgsql
不必使用密码?我删除了简单引号,但仍然没有密码:passuser\u pgsqlTry在PostgreSQL服务器上启用日志\u连接
,并查看是否有任何内容写入服务器日志。