Why can't thinkphp3.1 connect to the mysql database? please help me! thinkphp3.1 cannot connect to the mysql database. please help me !!! Project configuration file config. php: & lt ;? Phpreturnarray (& nbsp; APP_STATUS & gt; debug, & nbsp; DB_TYPE thinkphp3.1 cannot connect to the mysql database. please help me.
Thinkphp 3.1 cannot connect to the mysql database. please help me !!!
Project configuration file config. php:
Return array (
'App _ status' => 'debug ',
'Db _ type' => 'mysql', // Database TYPE
'Db _ host' => 'localhost', // server address
'Db _ name' => 'thinkphp', // database NAME
'Db _ user' => 'root', // USER name
'Db _ pwd' => '123', // password
'Db _ port' => '123', // PORT
'Db _ prefix' => 'think _ ', // database table PREFIX
'Db _ FIELDTYPE_CHECK '=> false, // whether to check the field type
'Db _ FIELDS_CACHE '=> true, // enable field caching
'Db _ charset' => 'gb2312', // 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
'Db _ MASTER_NUM '=> 1, // number of master servers after read/write splitting
'Db _ slave_no' => '', // specify the serial number of the slave server
'Db _ SQL _BUILD_CACHE '=> false, // create a cache for the SQL statement queried by the database
'Db _ SQL _BUILD_QUEUE '=> 'File', // The cache method of the SQL cache queue supports file xcache and apc.
'Db _ SQL _BUILD_LENGTH '=> 20, // The length of the SQL cache queue
'Db _ SQL _LOG '=> false, // SQL execution log records
);
?>
MYSQL contains a table in the thinkphp database and think_abc with the id int primary key auto_increment, name varchar (20), age int, and sex bool fields.
Controller file IndexAction. class. php:
Class IndexAction extends Action {
Public function index (){
$ Data = array (
'Name' => 'dong ',
'Age' => 21,
'Sex '=> 1
);
M ('ABC')-> add ($ data );
}
}
?>
Enter http: // localhost/app/index in the browser. "page error" is displayed in the browser after php. try 'http: // localhost/app/index later. php/index/has also tried to define other functions that do not connect to mysql here to run normally. I can't help beginners.
------ Solution --------------------
Delete the Runtime directory under the app and try again!
If not, send a message.