title: Warning: pg_query() expects parameter 1 to be resource, object given in C:\xampp\htdocs\grafig\read.php on line 6
body: <p>What's wrong in the code??</p>
  
  <pre><code>&lt;?php
  $host       =  "localhost";
  $dbuser     =  "tesdb";
  $dbpass     =  "123456";
  $dbname    =  "tesdb";
  
  // script koneksi php postgree
  $dbcon = new PDO("pgsql:dbname=$dbname;host=$host", $dbuser, $dbpass); 
  
  //$query ="SELECT * FROM air_tanah.pembayaran";
  $query ="select * from air_tanah.pembayaran";
  $result = pg_query($dbcon, $query) or die('Query failed');
  
    // output result
    while ($line = pg_fetch_array($result, null, PGSQL_ASSOC)) {
     echo "    Denda: " . $line['denda'] ."    Penyimpan: " . $line['Penyimpan'] .  "&lt;br/&gt;";
    }
  
    // free result
    pg_free_result($result);
  
    // close connection
    pg_close($dbcon);
  ?&gt;
  </code></pre>
  
  <p>and error like this</p>
  
  <p>Warning: pg_query() expects parameter 1 to be resource, object given in C:\xampp\htdocs\grafig\read.php on line 12
  Query failed</p>