Database PostgreSQL tidak bisa konek


Status
Not open for further replies.

BikinDesainSitus

Hosting Guru
Verified Provider
Halo teman-teman DWH,
saya mau konek database postgresql pakai kode ini
Code:
<?php
error_reporting(E_ALL);
ini_set('display_errors', true);

$dbconn = pg_connect("host=localhost port=5432 dbname=namaxxx user=xxx password=1xxxx");

$stat = pg_connection_status($dbconn);
if ($stat === PGSQL_CONNECTION_OK) {
    echo 'Connection status ok';
} else {
    echo 'Connection status bad';
}
?>
hasilnya selalu "Connection status bad"

status postgresql di whm up. user sudah di tambahkan ke db bersangkutan. sudah coba restart postgresql hasilnya tetap sama. coba buat db dan user baru jugaa sudah. gugling gak nemu2 jawaban.

terima kasih sebelumnya
 

sentabi

Expert 2.0
ga salah tu, fungsi buat ngecek loginnya berhasil atau ngga?
coba ganti
Code:
if ($stat === PGSQL_CONNECTION_OK)
Code:
if ($dbconn)
 

masiqbal

Hosting Guru
Verified Provider
Betul kata Tuan @sentabi
Untuk memastikan bisa juga begini:
PHP:
if (pg_connect("host=localhost port=5432 dbname=namaxxx user=xxx password=1xxxx")){
    echo 'Connection status ok';
} else {
    echo 'Connection status bad';
}
 
Status
Not open for further replies.

Top