I downloaded a thinkphp2.2 code from the Internet to connect to the thinkphp database, and created an index by myself. php, and then generate the project file, which is smooth, but cannot connect to the database. my code is very simple, & nbsp; $ modelnewModel (); & nbsp; $ model-& gt; query (& quot; select * fromthi thinkphp database connection
I downloaded a thinkphp2.2 code from the Internet, created an index. php, and generated the project file.
But I can't connect to the database. my code is very simple,
$ Model = new Model ();
$ Model-> query ("select * from think_person ;");
Conf/config. php file
Return array (
// 'Config maps '=> 'configuration value'
'Db _ type' => 'mysql', // Database TYPE
'Db _ host' => 'localhost', // server address
'Db _ name' => 'My _ table', // database NAME
'Db _ user' => 'root', // USER name
'Db _ pwd' => 'guozhixin ', // password
'Db _ port' => '123', // PORT
'Db _ prefix' => 'think _ ', // database table PREFIX
'Db _ SUFFIX '=> '', // database table SUFFIX
'Db _ FIELDTYPE_CHECK '=> false, // whether to check the field type
'Db _ FIELDS_CACHE '=> true, // enable field caching
'Db _ charset' => 'utf8', // The database encoding uses utf8 by default.
'Db _ DEPLOY_TYPE '=> 0, // Database deployment method: 0 centralized (single server), 1 distributed (master/slave server)
'Db _ RW_SEPARATE '=> false, // whether the master-slave mode is valid for database read/write splitting
);
The information is completely correct. I really don't know what's going on.
------ Solution --------------------
Your conf/config. php file contains
'Db _ pwd' => 'guozhixin ', // password
The error message is
Access denied for user 'root' @ 'localhost' (using password: NO)
Apparently, config. php is not loaded, or the path is incorrect.
Please delete all content in Runtime and try again