我下载了,安装了Xampp 1.8.0和1.5.0(针对不同版本的PHP)。它们都与HelloWorld程序一起工作,但是当我尝试运行CodeIgniter项目时,它会出现此错误。
它说“数据库中存在问题”和“无法使用数据库服务器提供的配置建立连接”。到处检查(CodeIgniter,Xampp,Wamp也)everysite和每个版本差不多。我该怎么办?
答案 0 :(得分:2)
如果您转到application
的{{1}}文件夹,则会有一个codeigniter
文件夹,其中包含名为config
的文件。此文件包含应用程序的数据库连接。
这样的事情:
database.php
IF 您在应用程序中使用数据库时,请确保此文件中的连接设置正确无误。
如果您未在应用程序中使用数据库,则可能是数据库连接正在自动加载,这会导致应用程序失败。在这种情况下,请转到/*
| -------------------------------------------------------------------
| DATABASE CONNECTIVITY SETTINGS
| -------------------------------------------------------------------
| This file will contain the settings needed to access your database.
|
| For complete instructions please consult the 'Database Connection'
| page of the User Guide.
|
| -------------------------------------------------------------------
| EXPLANATION OF VARIABLES
| -------------------------------------------------------------------
|
| ['hostname'] The hostname of your database server.
| ['username'] The username used to connect to the database
| ['password'] The password used to connect to the database
| ['database'] The name of the database you want to connect to
| ['dbdriver'] The database type. ie: mysql. Currently supported:
mysql, mysqli, postgre, odbc, mssql, sqlite, oci8
| ['dbprefix'] You can add an optional prefix, which will be added
| to the table name when using the Active Record class
| ['pconnect'] TRUE/FALSE - Whether to use a persistent connection
| ['db_debug'] TRUE/FALSE - Whether database errors should be displayed.
文件,该文件位于同一文件夹中并检查以下行:
autoload.php
如果/*
| -------------------------------------------------------------------
| Auto-load Libraries
| -------------------------------------------------------------------
| These are the classes located in the system/libraries folder
| or in your application/libraries folder.
|
| Prototype:
|
| $autoload['libraries'] = array('database', 'session', 'xmlrpc');
*/
$autoload['libraries'] = array('database');
正在自动加载,请将其从数组中删除,您的应用程序应该可以正常工作。