An error occurred while executing the index. php file. The database has been created. Error message: Warning: mysqli () [mysqli. mysqli] :( HY0002003): Can & #039; tconnecttoMySQLserveron & #039; localhost & #039; (10061) inD: apmxehtdocs28db_fns ....
An error occurred while executing the index. php file. The database has been created.
Error message:
Warning: mysqli () [mysqli. mysqli]: (HY000/2003): Can't connect to MySQL server on 'localhost' (10061) in D: \ apmxe \ htdocs \ 28 \ db_fns.php on line 5
Warning: mysqli: query () [mysqli. query]: Couldn't fetch mysqli in D: \ apmxe \ htdocs \ 28 \ index. php on line 8
Fatal error: Call to a member function fetch_assoc () on a non-object in D: \ apmxe \ htdocs \ 28 \ index. php on line 12
Development Environment: Apm express
How can we solve these problems?
Supplement: some code for connecting index. php to the database
$ Handle = db_connect (); $ pages_ SQL = 'select * from pages order by Code'; $ pages_result = $ handle-> query ($ pages_ SQL); echo'
'; While ($ pages = $ pages_result-> fetch_assoc ()) {$ story_ SQL = "select * from stories where page = '{$ pages ['code']}' and published is not null order by published desc "; $ story_result = $ handle-> query ($ story_ SQL); if ($ story_result-> num_rows) {$ story = $ story_result-> fetch_assoc (); echo"
{$ Pages ['description']} {$ Story ['headline']} Read more {$ pages ['code']}... |
";/* Db_connect function */function db_connect () {$ handle = new mysqli ('localhost', 'content', 'Password', 'content'); if (! $ Handle) {return false;} return $ handle ;} Reply content:An error occurred while executing the index. php file. The database has been created. Error message: Warning: mysqli () [mysqli. mysqli]: (HY000/2003): Can't connect to MySQL server on 'localhost' (10061) in D: \ apmxe \ htdocs \ 28 \ db_fns.php on line 5 Warning: mysqli: query () [mysqli. query]: Couldn't fetch mysqli in D: \ apmxe \ htdocs \ 28 \ index. php on line 8 Fatal error: Call to a member function fetch_assoc () on a non-object in D: \ apmxe \ htdocs \ 28 \ index. php on line 12 Development Environment: Apm express How can we solve these problems? Supplement: some code for connecting index. php to the database $ Handle = db_connect (); $ pages_ SQL = 'select * from pages order by Code'; $ pages_result = $ handle-> query ($ pages_ SQL); echo'
'; While ($ pages = $ pages_result-> fetch_assoc ()) {$ story_ SQL = "select * from stories where page = '{$ pages ['code']}' and published is not null order by published desc "; $ story_result = $ handle-> query ($ story_ SQL); if ($ story_result-> num_rows) {$ story = $ story_result-> fetch_assoc (); echo"
{$ Pages ['description']} {$ Story ['headline']} Read more {$ pages ['code']}... |
";/* Db_connect function */function db_connect () {$ handle = new mysqli ('localhost', 'content', 'Password', 'content'); if (! $ Handle) {return false;} return $ handle ;} Is the password of the mysqli link correct to all accounts ???? First confirm your constructionmysqli All the parameters are correct, and the four parameters areDatabase address, user name, password, Database Name. Check whether the database username and password are correct. Then confirm whether your database is started (many people forget it ). Enter telnet localhost 3306 Check whether it can be connected. |
|