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.