pg_fetch_array() error
<p>I tried to run this code to fill up a dropdown menu with data out of my database:</p>

<pre><code>&lt;?php

    if(isset($_GET["table"], $_GET["field"]))
        {
        require "opendb.php";

        $table = $_GET["table"];
        $field = $_GET["field"];

        $query =    "select '{$field}'
                    from '{$table}' "; 

        $data =  pg_query($conn, $query);

        $attribute_names = array();

        while ($row = pg_fetch_array($data))
        {
            array_push($attribute_names, $row[$field]);
        }

        print_r($row);

        echo json_encode($attribute_names);

        require "closedb.php";
    }
?&gt;
</code></pre>

<p>But I get this <strong>error</strong>:</p>

<blockquote>
  <p>pg_fetch_array() expects parameter 1 to be resource, boolean given in
  ...</p>
</blockquote>

<p>The thing is don't know if I can use teh variable $field in $row liike that.
So i don't know if this is possible <code>$row[$field]</code> .</p>