Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

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!

share|improve this question
    
"it never works!" is not an valid error message. –  Milen A. Radev Jan 9 at 22:31

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.