In my project, I am trying to use PostgreSQL to store user information like password, ID etc. I began using Heroku last week and I am having some trouble connecting to the database in PHP. My code looks like:
$db = pg_connect("host=<hostinfo>.amazonaws.com port=5432 dbname=<DatabaseName> user=oazjnfvmkdmslk password=<Password> sslmode=require options='--client_encoding=UTF8'");
if (!$db) {
echo "Database connection error."
exit;
}
# // test is a table with number column (1,2,3) and name column (joe, bill, steve)
$result = pg_query($db, "SELECT * FROM test WHERE number = '3'");
echo $result;
just as a test to see If I can connect to the database. Unfortunately, when I try to load the test page, it displays a blank page.
Any background information on postgresql database connection syntax and how to connect to a database in general would be appreciated!