title: postgresql select query not working
body: <p>I have a table <strong>lecturer</strong> with a column <strong>name</strong> and another <strong>department</strong>. I know for sure that one of the entries is <strong>name='Denis'</strong> and <strong>department='007'</strong>.
  This is the code:</p>
  
  <pre><code>&lt;?php 
        $names; $surname;
      require_once('connect_db.php'); 
      $firstname = pg_query(connect(), "SELECT name FROM keep_track");
      while($row = pg_fetch_array($firstname)){ $names = $row['path']." ".$row['name'];    }
      $lastname = pg_query(connect(), "SELECT surname FROM keep_track");
      while($row = pg_fetch_array($lastname)){ $surname = $row['path']." ".$row['surname'];    }
  
             echo '&lt;div id="show_dialog" class="ui-dialog-content ui-widget-content"&gt;';            
          echo "Lecturer: ".$names." ".$surname."&lt;br&gt;Department: ";
  
          require_once('connect_db.php'); 
          $a = pg_query(connect(), "SELECT department FROM lecturer WHERE name='$name'");
              while($row = pg_fetch_array($a)){ echo "Hi!!!";    }
  
          echo '&lt;/div&gt;';
  ?&gt;
  </code></pre>
  
  <p>But it doesnt echo anything. The variable $names has already been set and echoed in previous lines successfully and its value was set as John.
  The other queries Ive done are working fine. Idk why this one is not.</p>
  
  <p>Update:
  OK, I know why it doesn't work, but idk how to fix it. The problem is in this line: </p>
  
  <pre><code> $a = pg_query(connect(), "SELECT department FROM lecturer WHERE name='$name'");
  </code></pre>
  
  <p>I need to compare column name with variable $name, but it won't work like that. What is the right syntax? I am looking, but i havent been very successful till now</p>