Database PostgreSQL tidak bisa konek

Discussion in 'Desain Web dan Programming' started by BikinDesainSitus, 1 Jul 2015.

Thread Status:
Not open for further replies.
  1. BikinDesainSitus

    BikinDesainSitus Hosting Guru

    Messages:
    1,427
    Likes Received:
    84
    Trophy Points:
    48
    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
     
  2. sentabi

    sentabi Expert 1.0

    Messages:
    681
    Likes Received:
    35
    Trophy Points:
    28
    ga salah tu, fungsi buat ngecek loginnya berhasil atau ngga?
    coba ganti
    Code:
    if ($stat === PGSQL_CONNECTION_OK)
    Code:
    if ($dbconn)
     
  3. masiqbal

    masiqbal Expert 2.0

    Messages:
    864
    Likes Received:
    249
    Trophy Points:
    43
    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';
    }
     
  4. sentabi

    sentabi Expert 1.0

    Messages:
    681
    Likes Received:
    35
    Trophy Points:
    28
    itu sama aja kan sama yang aku buat diatas :D bedanya aku pake variable @masiqbal langsung dimasukin ke fungsinya.
     
Loading...
Thread Status:
Not open for further replies.

Share This Page

Loading...