DB Error: connect failed Postgresql and PHP
hi...
i wan to know how to create a user and database in postgresql.. The procedure i hav followed is as follows :- 1.i hav logged in as root. 2.using command "CREATEUSER root" created the user name as root 3.useing command "createdb sample" created database name as sample 4 then using "psql -U root sample" i i entered into the DB 5. I created a table name login using command create table login(name varchar(20),password varchar(20)); 6. then inserted 2 data's in it... but when i am tryin to access the database for inserting data using code written in PHP its giving an error "DB Error: connect failed" :confused: i am executing the program as : http://localhost/example my example folder is in /var/www/html directory and the folder example contain 2 php files.. 1.php,2.php 1.php :- its for takeing the data from user.. 2.php :- its contains the DB connection and insertion code the 2.php is as follows :- <?php include("DB.php"); $username="root"; $password=""; $hostname="localhost"; $dbname="sample"; $dsn="pgsql://$username:$password@$hostname/$dbname"; $db=DB::connect($dsn); if(PEAR::isError($db)) { die($db->getMessage()); } else { echo "FINE<br>"; } ?> apart from this i want to know through what function i can execute a query..because pg_query() is not workin in above code... The Postgresql Version installed in my system is psql (PostgreSQL) 8.0.3 Waitin for the reply...:) |
All times are GMT -5. The time now is 10:52 AM. |