【发布时间】:2016-12-26 17:13:31
【问题描述】:
我已成功将 codeigniter 项目推送到 cpanel 控制台。 除了数据库连接外,一切似乎都运行良好。 我相信我的设置是正确的,但我可能是错的。 下面是我的 database.php 脚本:
$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
);
我有以下错误:
遇到了 PHP 错误
严重性:警告
消息:mysqli::real_connect(): (HY000/1044): Access denied for user 'instadri_insta'@'localhost' 到数据库 'instadri_ver'
文件名:mysqli/mysqli_driver.php
行号:202
回溯:
文件:/home/instadri/application/controllers/Welcome.php 行:10 函数:__构造
文件:/home/instadri/public_html/index.php 行:319 功能: 需要一次
我也明白了:
遇到了 PHP 错误
严重性:警告
消息:无法修改标头信息 - 标头已由 (输出开始于 /home/instadri/system/core/Exceptions.php:272)
文件名:core/Common.php
行号:568
回溯:
文件:/home/instadri/application/controllers/Welcome.php 行:10 函数:__构造
文件:/home/instadri/public_html/index.php 行:319 功能: 需要一次
最后:
无法使用提供的设置连接到您的数据库服务器。
文件名:controllers/Welcome.php
行号:10
我已经处理了上述问题。 现在的新问题是 smarty 模板文件加载。 我有一个控制器可以做到这一点:
$this->smarty->view('front-theme/index.tpl', $data );
但我得到这个错误:
无法加载请求的文件: 前端主题/index.tpl
我的cpanel目录结构是:
- public_html
- index.php- 应用
- 系统公开
-_模板
-_cache
-前台主题
【问题讨论】:
-
再次检查是否创建了 db 用户。如果该用户与该数据库相关联。如果密码正确保存。顺便提一句。永远不要在这样的公共场所公开凭据。
-
您的数据库主机可能不再是您主机上的
localhost。检查以确保您拥有正确的主机。 -
大家好,我已经解决了这个问题。谢谢。我现在只剩下一个问题了。我的 smarty 没有加载。
标签: mysql codeigniter mysqli smarty cpanel