Fatal error: Call to undefined function pg_connect()

后端 未结 17 1426
广开言路
广开言路 2020-12-02 23:07

I am trying to connect to my database (remote server) which has PostgreSQL installed in it. My PHP code is trying to connect to the database using pg_connect(), but I get th

相关标签:
17条回答
  • 2020-12-02 23:18

    On Gentoo, use USE flag postgres in /etc/portage/make.conf and re emerge "emerge php"

    0 讨论(0)
  • 2020-12-02 23:21
    1. Add 'PHPIniDir "C:/php"' into the httpd.conf file.(provided you have your PHP saved in C:, or else give the location where PHP is saved.)
    2. Uncomment following 'extension=php_pgsql.dll' in php.ini file
    3. Uncomment ';extension_dir = "ext"' in php.ini directory
    0 讨论(0)
  • 2020-12-02 23:21

    I encountered this error and it ended up being related to how PHP's extension_dir was loading.

    If upon printing out phpinfo() you find that under the PDO header PDO drivers is set to no value, you may want to check that you are successfully loading your extension directory as detailed in this post:

    https://stackoverflow.com/a/14786808/2578505

    0 讨论(0)
  • 2020-12-02 23:22

    You need to install the php-pgsql package or whatever it's called for your platform. Which I don't think you said by the way.

    On Ubuntu and Debian:

    sudo apt-get install php5-pgsql
    
    0 讨论(0)
  • 2020-12-02 23:27

    I also had this problem on OSX. The solution was uncommenting the extension = pgsql.so in php.ini.default and deleting the .default suffix, since the file php.ini was not there.

    If you are using XAMPP, the php.ini file resides in /XAMPP/xampfiles/etc

    0 讨论(0)
  • 2020-12-02 23:28

    For php 5.4 on Centos 6.10, we include these lines in php.ini

    extension=/opt/remi/php54/root/usr/lib64/php/modules/pdo.so
    extension=/opt/remi/php54/root/usr/lib64/php/modules/pgsql.so
    extension=/opt/remi/php54/root/usr/lib64/php/modules/pdo_pgsql.so
    

    It works.

    0 讨论(0)
提交回复
热议问题