2012-08-27 23 views
0

我下載了,安裝了Xampp 1.8.0和1.5.0(針對不同版本的PHP)。它們都與HelloWorld程序一起工作,但是當我嘗試運行CodeIgniter項目時,會出現此錯誤。 ErrorXampp未知錯誤當我嘗試運行用CodeIgniter編寫的項目

它說「數據庫中存在問題」和「無法使用數據庫服務器提供的配置建立連接」。無處不在(CodeIgniter,Xampp,Wamp也)everysite和每個版本差不多。我該怎麼辦?

回答

2

如果您轉到application文件夾codeigniter,將會出現一個config文件夾,其中包含一個名爲database.php的文件。該文件包含應用程序的數據庫連接。

事情是這樣的:

/* 
| ------------------------------------------------------------------- 
| 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. 

IF您使用的應用程序中的數據庫,請確保該文件中的連接設置是否正確。

如果您在應用程序中未使用數據庫,則可能是數據庫連接正在自動加載,這會導致應用程序失敗。在這種情況下,去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'); 

如果database被自動加載,從數組中刪除它,你的應用程序應該只是罰款。

+0

謝謝,我會盡力,謝謝。 – ag0702

+0

非常感謝你解決了我的問題,我正在檢查代碼,所以數據庫用戶名等不同,再次感謝你。 – ag0702

相關問題