I've written a code to test postgres in php and I get the following errors
Warning: pg_connect() unable to connect to PostgreSQL server: FATAL 1: user "apache" does not exist in /var/www/html/testdb.php on line 2
Warning: pg_exec(): supplied argument is not a valid PostgreSQL link resource in /var/www/html/testdb.php on line 4
There's been an error
and my code:
<?php
$conn=pg_connect("dbname =mobiledb");
$sql = "select * from users";
$result = pg_exec($conn,$sql);
if (!$result) {printf("There's been an error");exit;}
$row=pg_fetch_row($result,0);
printf("Phone number:%s<br>\n",$row[1]);
printf("Service Provider:%s<br>\n",$row[2]);
pg_close();
?>
What am I doing wrong?
php errors
Moderator: General Moderators
- Love_Daddy
- Forum Commoner
- Posts: 61
- Joined: Wed Jul 10, 2002 6:55 am
- Location: South Africa
- Contact:
or use a valid account for the database
http://www.php.net/manual/en/function.pg-connect.php wrote:$dbconn3 = pg_connect ("host=sheep port=5432 dbname=mary user=lamb password=foo");
- Love_Daddy
- Forum Commoner
- Posts: 61
- Joined: Wed Jul 10, 2002 6:55 am
- Location: South Africa
- Contact:
My error
Hi all,
I managed to figure the problem out.
All I needed to do was to create apache as a user and it worked fine.
I managed to figure the problem out.
All I needed to do was to create apache as a user and it worked fine.