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, it never works!

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 1 hour ago
add comment

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

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.