我已經成功地將一個codeigniter項目推送到一個cpanel控制檯。 除了數據庫連接,一切似乎都正常工作。 我相信我的設置正確,但我可能是錯的。 下面是我database.php中腳本:Codeigniter Cpanel Mysql數據庫設置
$active_group = 'default';
$query_builder = TRUE;
$db['default'] = array(
'dsn' => '',
'hostname' => 'localhost',
'username' => 'instadri_insta',
'password' => 'BL9w;K;ds9MR',
'database' => 'instadri_ver',
'dbdriver' => 'mysqli',
'dbprefix' => '',
'pconnect' => FALSE,
'db_debug' => TRUE,
'cache_on' => FALSE,
'cachedir' => '',
'char_set' => 'utf8',
'dbcollat' => 'utf8_general_ci',
'swap_pre' => '',
'encrypt' => FALSE,
'compress' => FALSE,
'stricton' => FALSE,
'failover' => array(),
'save_queries' => TRUE
);
我有以下錯誤:
A PHP Error was encountered
Severity: Warning
Message: mysqli::real_connect(): (HY000/1044): Access denied for user 'instadri_insta'@'localhost' to database 'instadri_ver'
Filename: mysqli/mysqli_driver.php
Line Number: 202
Backtrace:
File: /home/instadri/application/controllers/Welcome.php Line: 10 Function: __construct
File: /home/instadri/public_html/index.php Line: 319 Function: require_once
我也得到:
A PHP Error was encountered
Severity: Warning
Message: Cannot modify header information - headers already sent by (output started at /home/instadri/system/core/Exceptions.php:272)
Filename: core/Common.php
Line Number: 568
Backtrace:
File: /home/instadri/application/controllers/Welcome.php Line: 10 Function: __construct
File: /home/instadri/public_html/index.php Line: 319 Function: require_once
最後:
Unable to connect to your database server using the provided settings.
Filename: controllers/Welcome.php
Line Number: 10
我已經照顧了上述情況。 現在的新問題是加載smarty模板文件。 我有一個控制器,這是否:
$this->smarty->view('front-theme/index.tpl', $data);
,但我得到這個錯誤:
Unable to load the requested file: front-theme/index.tpl
我的cPanel目錄結構:
- public_html
- index.php- application
- system public
-_template
-_cache
-front-theme
仔細檢查是否創建了db用戶。如果該用戶與該數據庫關聯。如果密碼正確保存。順便說一句。絕不要在這樣的公共場所暴露證件。 – Tpojka
您的主機數據庫可能不再是您的主機上的'localhost'。檢查以確保您擁有合適的主機。 – coderodour
嗨,我已經解決了這個問題。謝謝。 我現在只剩下一個問題。 我的聰明沒有加載。 –