为什么我无法连接到我的 psql 数据库?
Why can't I connect to my psql db?
所以我正在尝试 link 我的页面 a.php 到我的 psql 数据库。
这是DBConnection.class.php:
<?php
class DBConnection
{
var $conn
function DBConnection();
{
$this->conn = pg_connect("host='localhost' port='5432' dbname='tester' user='postgres' password='password'") or die("unable to connect");
}
}
?>
这里是 a.php
<?php
include ("DBConnection.class.php");
$DBConnection = new DBConnection();
?>
它一直告诉我我在 DBConnection 的第 7 行有一个错误:致命错误:非抽象方法 DBConnection::DBConnection() must contain body in C:\wamp\www\DBConnection.class.php第 7 行
就解决这个问题而言,我不完全确定我做了什么
Open php.ini
Find ;extension=php_pgsql.dll and remove the initial semi colon
Find ;extension=php_pdo_pgsql.dll and remove the initial semi colon
Save the file
Restart apache
删除
;
从函数名末尾开始
class DBConnection
{
var $conn
function DBConnection()
{
$this->conn = pg_connect("host='localhost' port='5432' dbname='tester' user='postgres' password='password'") or die("unable to connect");
}
}
?>
所以我正在尝试 link 我的页面 a.php 到我的 psql 数据库。
这是DBConnection.class.php:
<?php
class DBConnection
{
var $conn
function DBConnection();
{
$this->conn = pg_connect("host='localhost' port='5432' dbname='tester' user='postgres' password='password'") or die("unable to connect");
}
}
?>
这里是 a.php
<?php
include ("DBConnection.class.php");
$DBConnection = new DBConnection();
?>
它一直告诉我我在 DBConnection 的第 7 行有一个错误:致命错误:非抽象方法 DBConnection::DBConnection() must contain body in C:\wamp\www\DBConnection.class.php第 7 行
就解决这个问题而言,我不完全确定我做了什么
Open php.ini
Find ;extension=php_pgsql.dll and remove the initial semi colon
Find ;extension=php_pdo_pgsql.dll and remove the initial semi colon
Save the file
Restart apache
删除
;
从函数名末尾开始
class DBConnection
{
var $conn
function DBConnection()
{
$this->conn = pg_connect("host='localhost' port='5432' dbname='tester' user='postgres' password='password'") or die("unable to connect");
}
}
?>