dqluw20882 2013-05-14 19:08
浏览 15

路线不在Codeigniter中工作

I'm using CodeIgniter 1.9 to build a website.

I want http://myurl.com/index.php/user/profile/2 to take me to the Profile Page for the user with the id of 2.

My routes.php file looks like this.

$route['default_controller'] = 'welcome';
$route['404_override'] = '';
$route['user/profile/(:num)'] = 'user/profile_view/$1';

My user.php file looks like this.

class User extends CI_Controller {

    function __construct()
    {
        parent::__construct();
        $this->load->model('user_model');
    }

    function profile_view($id)
    {
            $data = array();
        log_message("info", "I am in the profile_view method of user.php.");

        $this->load->view("templates/header", $data);
        $this->load->view("templates/footer", $data);
    }
}

The code is never making it to the log_message() function and it is throwing a 500 error that says exactly this...

HTTP Error 500 (Internal Server Error): An unexpected condition was encountered while the server was attempting to fulfil the request.

Any help would be greatly appreciated. I've been looking for several hours now with no luck.

  • 写回答

3条回答 默认 最新

  • douren6035 2013-05-14 19:13
    关注

    The $data you pass is not initialize. Probably your error 500 comes from it. Before log_message, type this statement:

    $data = array();
    

    Tell us if you have an error after this correction.

    评论

报告相同问题?

悬赏问题

  • ¥15 随身WiFi网络灯亮但是没有网络,如何解决?
  • ¥15 gdf格式的脑电数据如何处理matlab
  • ¥20 重新写的代码替换了之后运行hbuliderx就这样了
  • ¥100 监控抖音用户作品更新可以微信公众号提醒
  • ¥15 UE5 如何可以不渲染HDRIBackdrop背景
  • ¥70 2048小游戏毕设项目
  • ¥20 mysql架构,按照姓名分表
  • ¥15 MATLAB实现区间[a,b]上的Gauss-Legendre积分
  • ¥15 delphi webbrowser组件网页下拉菜单自动选择问题
  • ¥15 linux驱动,linux应用,多线程