How to solve the problem that php cannot connect to postgresql data in linux

Source: Internet
Author: User

When logging on to phpPgAdmin: If you always get a "Login failed" and confirm that you have used the correct username and password and can log on normally in pgadminIII! Solution: Modify php. in the ini configuration file, set extension = pgsql. so it is OK to comment out this line. The changed form is as follows:; For example:; extension = msql. so; extension = pgsql. so this is very simple, but I did not find a solution on the Internet for a day. I only need to carefully check the php. in ini, we can see that all the mysql configurations in one line are commented out. Take a try and put pgsql. so is also commented out. Haha, it's a pleasure to be successful! After the change, the problem that the postgresql-connected program previously written in php cannot be connected is also solved. Attached test code: // connection, select database $ dbconn = pg_connect ("host = localhost dbname = testdb user = lyb password = dbmanage "); // see if our connection was successful if (! $ Dbconn) {// connection failed-exit the page with an error // you cocould also try to proceed without the // database-it's up to you echo "connection failed, cannot connect to Database "; exit;} else {echo" connection successful ";} echo"
Php configuration details: "; echo phpinfo (); // close the connection pg_close ($ dbconn);?> Note: My environment is: CentOS4.4 apache and php both come with postgresql 8.1 (compiled and installed by yourself)

Related Article

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.