在我的控制器(控制器/ user.php的),我有:笨不加载模型
class User extends CI_Controller
{
public function index()
{
$this->load->model('user_model')or die("error");
}
}
在我的模型(模型/ user_model.php),我有
class User_model extends CI_Model
{
public function __construct()
{
parent::__construct();
$this->load->database();
$this->load->helper('common');
}
}
如果我从加载语句中删除
or die("error");
我得到一个500内部服务器错误。
我检查的config.php和这里的一些信息
$config['base_url'] = '';
$config['index_page'] = '';
$config['uri_protocol'] = 'AUTO';
我还编辑.htaccess文件从URL删除“的index.php”,使之清洁。
RewriteEngine On
RewriteCond $1 !^(index.php|images|captcha|css|js|robots.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
本地主机,或测试/现场网站在线? – sinisake
我现在正在测试这个地方。 MAMP – Lance
缩小范围 - 删除'$ this-> load->模型('user_model')或死(“error”);'并且将echo'a';出口; 如果它给了你'一个',那么你的问题与模型有关。接下来你应该检查你的application/config/database.php的配置。你可以在$ this-> load-> database()后退出。 (加载助手之前),看看它是否是数据库连接 – galchen