Database connection problems

Source: Internet
Author: User
Database connection problem PHPcode file 1 $ search_db = newSearchDo (); if ($ search_db-& gt; connect () = false) {// database connection exit ;} if ($ area_k1__id = '') {database connection problem
PHP code
  File 1 $ search_db = new SearchDo (); if ($ search_db-> connect () = false) {// database connection exit ;} if ($ area_k1__id = '') {// region $ list_area = new AreaList (); $ area_list = $ list_area-> createList (); $ smarty-> assign ('area _ list', $ area_list);} else {$ area_list = $ search_db-> getAreaById ($ area_k1__id ); $ smarty-> assign ('area _ list', $ area_list);} File 2 class AreaList extends SelectList {function AreaList () {$ SQL = SQL _AREA_LIST_SELECT; $ this-> SQL = $ SQL; $ this-> SelectList () ;}} file 3 class SelectList extends BoatDb {function SelectList () {$ this-> BoatDb (); $ this-> connect (); // database connection} function createList () {-- database operation -- $ this-> close (); // close the connection }}


The error is not a valid PostgreSQL link resource.

------ Solution --------------------
Check the content of the connect () function to see if server, username, password, and db are correct.
------ Solution --------------------
Otherwise, unless the database is reconnected.
------ Solution --------------------
No effect!
When initiating a database connection, php first checks whether the connection has been established. if the connection has been established, php does not actually connect to the database and directly returns the existing connection.

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.