VDS Sphera Knowledge Base
| Main / Browse Categories / PostgreSQL / How can I connect to PostgreSQL using PHP? |
How can I connect to PostgreSQL using PHP?
If you are having trouble connecting to a Postgresql Database from within php, try the following pg_connect syntax:
<?php
$database=pg_Connect("dbname=YOUR_DB_NAME");
Replace YOUR_DB_NAME with the actual name of your database. You can test the results by executing the following:
if(!$database){
die("Could not connect -> " . pg_errormessage($database));
}
?>
A nice tutorial, Using PostgreSQL With PHP, is also available here.
User Comments
|
||||||||
Attachments
| No attachments. |
Related Articles


