title: Warning: pg_query() expects parameter 1 to be string, resource given in
body: <p>I wanted to show my database but I have this error:</p>
  
  <blockquote>
    <p>Warning: pg_query() expects parameter 1 to be string, resource given in</p>
  </blockquote>
  
  <pre><code>&lt;?php
  session_start();
  pg_connect("host=localhost port=5432 dbname=base_test user=postgres password=123456") or die('Could not connect: ' . pg_last_error());
  
  $q=pg_query("select timestamp, outdoor, indoor from align_data");
  $query=pg_query($q);
  $n=pg_num_rows($query);
  for($i=0; $i&lt;$n; $i++)
  {
      $f=pg_fetch_row($query1);
      echo("['".$f[0]."',  ".$f[1].", ".$f[2]."], ");
  }                           
  ?&gt;
  </code></pre>