Fatal error: Call to undefined function pg_connect()

后端 未结 17 1427
广开言路
广开言路 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:39

    Edit. I just noticed you were mentionning MAMP. My advice is for Windows but may be useful if you know what corresponding tools to use.

    Things to try:

    • Have you restarted PHP and Apache since your editing of php.ini?

    • Is the php_pgsql.dll found in your php\ext directory?

    • Are you running php as a module? If so, try copying the php_pgsql.dll file in the Apache\bin directory.

    • Are you running PHP from the command line with a flag specifying a different php.ini file?

    • You could try using a tool such as Sysinternals' Filemon to view what files are attempting to be accessed when running PHP.

    • You could try using a tool such as Dependency Walker to look at the dependencies for the postgreSQL DLL, in case you have a missing dependency. Quick search brought up ldd for Unix.

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

    If you got php5.6 using the ppa repository http://ppa.launchpad.net/ondrej/php/ubuntu,

    then you should install the package using:

    sudo apt install php5.6-pgsql

    Finally, if you use apache2, restart it:

    sudo service apache2 restart

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

    Fatal error: Call to undefined function pg_connect()...

    I had this error when I was installing Lampp or xampp in Archlinux,

    The solution was edit the php.ini, it is located in /opt/lampp/etc/php.ini

    then find this line and uncomment

    extension="pgsql.so"
    

    then restart the server apache with xampp and test...

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

    Easy install for ubuntu:

    Just run:

    sudo apt-get install php5-pgsql
    

    then

    sudo service apache2 restart //restart apache
    

    or

    Uncomment the following in php.ini by removing the ;

    ;extension=php_pgsql.dll
    

    then restart apache

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

    For those of you who have this problem with PHP 5.6, you can use the following command:

    yum install php56w-pgsql
    

    For a list of more package names for PHP 5.6, open the following link and scroll down to packages:

    PHP 5.6 on CentOS/RHEL 7.0 and 6.6 via Yum

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