PHP Fatal error:call to undefined function pg_connect ()

Source: Internet
Author: User
Tags postgresql

Yesterday, I wanted to use PHP code to read all the data table information from a local PostgreSQL database, and when I joined the database, there was an error fatal Error:call to undefined function pg_connect (). The extension to Pgsql was not turned on. So I removed the semicolon before the ' Extension=php_pgsql.dll ' in php.ini, but the problem still remained unresolved.

Tried this afternoon to run a connection PostgreSQL PHP code in the CLI, and the result passed. Suspected of being used in php.ini and servers used in the CLI. PHP.ini inconsistent results, so look at it, they are not the same php.ini configuration file, but the contents of the two files are identical, and the PHP version number is the same, are PHP5.3.6, this is strange.

Google, Baidu has many times, looked at almost all the relevant issues of the Web page, tried a variety of methods (including copy DLL to C disk system directory, add environment variables, etc., in addition to a PHP version), eventually failed to solve the problem.

is ready to change a PHP version of the former, suddenly thought of Baidu Encyclopedia to see the PHP PostgreSQL, MySQL and other databases, the result unexpectedly in the PHP installation of the problem saw the reason: did not copy pgsql dll to the system32 directory, Causes PHP to not recognize these functions such as pg_connect.

So, the ./php/libpq.dll(Libpq.dll under the PHP folder) and the ./php/ext/php_pgsql.dll(The PHP_ under the Ext folder) Pgsql.dll) These two DLL files are copied to the C disk System32 and then viewed Phpinfo () and found that the module pgsql appears in the list.

Then, the table information in the database was successfully read.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.