Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/243.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/69.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
pg_connect不适用于PHP5_Php_Sql_Postgresql - Fatal编程技术网

pg_connect不适用于PHP5

pg_connect不适用于PHP5,php,sql,postgresql,Php,Sql,Postgresql,我正在开发一个在Windows8服务器上使用PHP4运行良好的应用程序。我正在使用postgres设置一个本地服务器,以便在本地工作,但使用PHP5可以迁移一些东西。我有一些兼容性问题,但没什么大问题,只是类中的pg_connect函数不起作用,不会给我带来任何错误 class basededatos{ var $link_; function basededatos(){ $this->link_=pg_connect("host=localhost p

我正在开发一个在Windows8服务器上使用PHP4运行良好的应用程序。我正在使用postgres设置一个本地服务器,以便在本地工作,但使用PHP5可以迁移一些东西。我有一些兼容性问题,但没什么大问题,只是类中的pg_connect函数不起作用,不会给我带来任何错误

class basededatos{
    var $link_;

    function basededatos(){
        $this->link_=pg_connect("host=localhost port=5432 dbname=... user=postgres password=...") or die('Falla en la conexión a la Base de Datos. Por favor, Revise la Configuración.');
    }

    function cerrarconexion(){
        pg_close($this->link_);
    }

    function Abreconexionconretorno($consulta){
        $resultado=pg_query($consulta)or die("La consulta falló con error: ".pg_last_error());
        return $resultado;
    }

    function Abreconexionsinretorno($consulta){
        pg_query($consulta)or die("La consulta falló con error: ".pg_last_error());
    }
}
此后

$this->link_=pg_connect(...)

它死了,知道为什么会这样吗?谢谢

可能您没有在php.ini文件中启用PostreSQL扩展,因为您升级到了PHP5。如果安装了用于php的pgsql模块,只需将这一行添加到php.ini:

extension=php\u pgsql.dll
(windows)

extension=php\u pgsql.so
(linux)

如果未安装模块,请执行以下操作:

sudo apt-get install php5-pgsql

可能您没有在php.ini文件中启用PostreSQL扩展,因为您升级到了PHP5。如果安装了用于php的pgsql模块,只需将这一行添加到php.ini:

extension=php\u pgsql.dll
(windows)

extension=php\u pgsql.so
(linux)

如果未安装模块,请执行以下操作:

sudo apt-get install php5-pgsql

非常感谢。我想如果不安装它会出错谢谢!我想如果没有安装,它会出错