Welcome Guest, Not a member yet? Register   Sign In
How to handle eror message in controller ?
#1

[eluser]Edy S[/eluser]
Hi Everybody, i have a problem with my controller programs.
Here's my code :
Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Home extends CI_Controller {


      function __construct(){
      session_start();
      parent::__construct();
    }
    
    public function index()
    {    
        //load config file
        $this->load->model('conf');
        $setting = $this->conf->webconfig();
        $query   = $this->db->query('SELECT * FROM myTable WHERE FrontPage="1"');
        $data['prm']    = '';
        $data['date']    = $setting['date'];
        $data['home']    = $query->row();
        $this->load->view('template_1',$data);
    }
    
    public function pages($id)
    {    
        $query = $this->db->query("SELECT * FROM myTable WHERE myKey='".$id."'");
        $data['pages']= $query->result();
        $data['prm']  = '';
        $data['mode'] = 'pages';
        $this->load->view('template',$data);
    }

}

It will display error message and disturb the website display when people visit http://www.mysite.com/home/pages/ without insert a value for $id
And my question now, How to handle an empty $id, so that it will not display an error message ?


Messages In This Thread
How to handle eror message in controller ? - by El Forum - 08-13-2011, 08:01 AM
How to handle eror message in controller ? - by El Forum - 08-13-2011, 08:29 AM
How to handle eror message in controller ? - by El Forum - 08-13-2011, 08:30 AM
How to handle eror message in controller ? - by El Forum - 08-13-2011, 09:00 AM



Theme © iAndrew 2016 - Forum software by © MyBB