title: how to catch pg_connect() function error?
body: <p>pg_connect() is showing the error in table format.Instead of showing error message as table format need a error message alert. </p>
  
  <blockquote>
    <p>Error Message<br>
      Warning: pg_connect() [function.pg-connect]: Unable to connect to PostgreSQL server: FATAL: password authentication failed for user "test" in /home/test/public_html/QueueManager/Modules/Database.php on line 41 </p>
  </blockquote>
  
  <p>After if showing error as table format.<br>
  After executing pg_connect() throwed exception.<br>
  But is is not working.</p>
  
  <p>Code</p>
  
  <pre><code>function connect()
  {
    $HOST = $GLOBALS[Database_Conn][Db_Host];     # Host name 
    $USER = $GLOBALS[Database_Conn][Db_User];     # database user name 
    $DBNAME = $GLOBALS[Database_Conn][Db_Name];   # name of the database
    $PASSWORD = $GLOBALS[Database_Conn][Db_Pass]; # password the database user.
  
    try 
    {
      $conn = pg_connect("host=$HOST dbname=$DBNAME user=$USER ".
                         "password=$PASSWORD sslmode=disable");
      if(!$conn)
      {
        throw new Exception("Database Connection Error");
      }
      return $conn;
    }
    catch (Exception $e) 
    {
      print &lt;&lt;&lt;_HTML_
      &lt;script&gt; alert('Caught exception'); 
      &lt;/script&gt; _HTML_;
      die();
    }
  }
  </code></pre>
  
  <p>Please give me the solution</p>