
August 9th, 2012, 07:37 AM
|
|
Registered User
|
|
Join Date: Aug 2012
Posts: 2
Time spent in forums: 29 m
Reputation Power: 0
|
|
|
Code help to query database
I am very new to Postgresql and I have a bit of code which I can't see any problem with but it doesn't return anything, hope someone can tell me where I am going wrong.
PHP Code:
$conn = pg_pconnect ("host=localhost port=5433 dbname=timetrex user=timetrex password=password");
if (!$conn) { echo "An error occured.\n";
exit;
}
$result = pg_query ($conn, "SELECT * FROM users");
if (!$result) { echo "An error occured.\n";
exit;
}
$arr = pg_fetch_all ($result, 0, PGSQL_NUM);
var_dump($arr);
I have checked the port, username, password etc and all is fine, it does appear to connect to the database but doesn't return the result of the query.
|