Skip to main content

How to Display Error Message in CodeIgniter

In this tutorial, I will explain on how to you can display error messages using CodeIgniter into your View from a Controller. There are two kinds of approach of doing this. First, passing the data directly from Controller to View. Second, using flashdata. This code is useful, for example, if you have a shopping cart application. Say you want to display an error message telling your visitor that the cart is empty. First approach: To do this, add the following in your Controller:
  2. if (!$this->cart->contents())
  3. {
  4. $this->data['err_message'] = 'Your cart is empty!';
  5. }


Submitted byvishal kumar (not verified)on Mon, 08/25/2014 - 18:11

Please tell me hoe to make my codeiginiter website live as it is very well running on local host
Submitted byCI_user (not verified)on Thu, 01/01/2015 - 00:25


Are you serious? You are not talking about error message but the way to pass a message you've created to the view. With this kind of title I was expecting to find out how to display real error message in order to debugg a developping issue. Please change your title, the content has not really the same meaning.

Add new comment