title: To solve a pg_query error message in PHP
body: <p><strong>My code handler.php</strong></p>
  
  <pre><code> ... 
   // independent variables
   $dbHost = "localhost";
   $dbPort = 5432;
   $dbName = "masi";
   $dbUser = "masi";
   $dbPassword = "123456";
  
   $conn = "host=$dbHost port=$dbPort dbname=$dbName user=$dbUser password=$dbPassword";
  
  $dbconn = pg_connect($conn);
  
  $sql = "SELECT username, passhash_md5, email 
           FROM users$
           WHERE username='a'        // to get these data from lomake.php
           AND email='a' 
           AND passhash_md5='a'";
  
       $result = pg_query($conn, $sql);
       if(!$result) {
           echo "An error occurred - Masiii!\n";
           exit;
       }
  ?&gt;
  </code></pre>
  
  <p>I put "username=a", "email=a" and password="a" to a form which processes the script handler.php in Firefox. I get</p>
  
  <pre><code>Warning: pg_query(): supplied argument is not a valid PostgreSQL link resource in /var/www/sivusto/handler.php on line 56
  An error occurred - Masiii! 
  </code></pre>
  
  <p>I am not sure where the bug is, since I use the same syntax as <a href="http://us2.php.net/manual/en/function.pg-query.php" rel="nofollow noreferrer">some examples at PHP.net</a>.</p>
  
  <p><strong>How can you solve the bug?</strong></p>