connecting php with postgresql
<p>I am a newcomer and have just started building a website.. I wrote the following code but its not working.it is not connecting to the database..If not this is there any other way to connect dreamweaver to postgresql ...please help..thnx in advance</p>

<pre><code>&lt;!DOCTYPE html&gt;

&lt;html lang="en"&gt;
&lt;head&gt;
&lt;meta charset="utf-8"&gt; 
&lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&gt;
&lt;!-- Bootstrap --&gt;
&lt;link href="css/bootstrap.min.css" rel="stylesheet" media="screen"&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;div class="span6"&gt;
  &lt;table class="table table-striped"&gt;
     &lt;thead&gt;  
          &lt;tr&gt;  
            &lt;th&gt;Scheme-ID&lt;/th&gt;  
            &lt;th&gt;Scheme Name&lt;/th&gt;  
            &lt;th&gt;Scheme Type&lt;/th&gt;  

          &lt;/tr&gt;  
        &lt;/thead&gt;
        &lt;tbody&gt;
&lt;?PHP


        $conn = pg_connect("host=localhost port=5432 dbname=egram user=postgres password=password") or die("unable to connect to database");
        if ($conn) 
        {   

        echo ("Connection attempt succeeded.");   

        }
         else {   

        echo ("Connection attempt failed.");   

        } 

    $sql = "SELECT scheme_id,scheme_name,scheme_type FROM schemes";
    $result = pg_query($conn,$sql);  //order executes
    if($result)
    {
        echo("query ran successfully");
        while($data = pg_fetch_row($result))
        {
            echo("&lt;tr&gt;&lt;td&gt;$data[0]&lt;/td&gt;&lt;td&gt;$data[1]&lt;/td&gt;&lt;td&gt;$data[2]&lt;/td&gt;&lt;/tr&gt;");
        }
    }
    else
    {
        echo("error in running query");
    }

?&gt;

    &lt;/tbody&gt;  
    &lt;/table&gt;
    &lt;/div&gt;
    &lt;script src="http://code.jquery.com/jquery.js"&gt;&lt;/script&gt;
    &lt;script src="js/bootstrap.min.js"&gt;&lt;/script&gt;
  &lt;a href="#"&gt;#&lt;/a&gt;
  &lt;/body&gt;
&lt;/html&gt;
</code></pre>
