Thread: Unable to connect To Database...
<p> <br /> hi...<br /> I am doin my project in PHP with PostgreSQL as backend...<br /> Both r very new to me....<br/> My OS is LINUX <br /> I am trying to connect to the database bt its not getin connected...<br /> By using<br/> "su posgres" command<br /> i hav created user "root" and database "sample"<br /> By using<br /> "psql -U root sample" command<br /> i hav created table "login" and inserted 3 data's...<br /> now through code usingPHP i am trying to insert the data but connection is not getin established.. <br /> the code to connect to the datadaseis :-<br /> <br /> <?php<br /> require_once "DB.php";<br /> $uname=$_POST['uname'];<br /> $pass=$_POST['pass'];<br/><br /> $username="root";<br /> $password="";<br /> $hostname="localhost";<br /> $dbname="sample";<br/><br /> $db=new DB;<br /> $dsource=$db->factory("pgsql");<br /><br /> $dcon=pg_connect("dbname=sampleuser=manashi");<br /><br /> $sql="insert into login values('$uname','$pass')";<br /><br/> $rs=$dsource->pg_query($sql);<br /> ?><br /><br /> is there anythin wrong with the code or sum other problem<br/> waiting for the reply... <br /><br /><a href="http://adworks.rediff.com/cgi-bin/AdWorks/sigclick.cgi/www.rediff.com/signature-home.htm/1507191490@Middle5?PARTNER=3"><img border="0"hspace="0" src="http://adworks.rediff.com/cgi-bin/AdWorks/sigimpress.cgi/www.rediff.com/signature-home.htm/1963059423@Middle5?OAS_query=null&PARTNER=3" vspace="0"/></a>