title: call a helper function in controller in codeigniter
body: <p>I created a helper for visit hits and it contains a function which inserts some data in to the database:</p>
  
  <p><strong>hits_counter_helper.php</strong> :</p>
  
  <pre><code>function count_hits($options = array())
  {
  
      //Determine whether the user agent browsing your site is a web browser, a mobile device, or a robot.
      if ($this-&gt;agent-&gt;is_browser())
      {
          $agent = $this-&gt;agent-&gt;browser() . ' ' . $this-&gt;agent-&gt;version() . ' - ' . $this-&gt;agent-&gt;platform();
      }
      elseif ($this-&gt;agent-&gt;is_robot())
      {
          $agent = $this-&gt;agent-&gt;robot();
      }
      elseif ($this-&gt;agent-&gt;is_mobile())
      {
          $agent = $this-&gt;agent-&gt;mobile();
      }
      else
      {
          $agent = 'Unidentified User Agent';
      }
  
      //Detect if the user is referred from another page
      if ($this-&gt;agent-&gt;is_referral())
      {
          $referrer = $this-&gt;agent-&gt;referrer();
      }
  
      // correcting date time difference by adding 563 to it.
      $date = date('Y-m-j H:i:s', strtotime(date('Y-m-j H:i:s')) + 563);
  
      $data = array (
  
          'page_Address'  =&gt;   current_url(),
  
          'user_IP'       =&gt;   $this-&gt;input-&gt;ip_address(),
  
          'user_Agent'    =&gt;   $agent,
  
          'user_Referrer' =&gt;   $referrer,
  
          'hit_Date'      =&gt;   $date
  
      );
  
      $this-&gt;db-&gt;insert('counter', $data);
  
  }
  </code></pre>
  
  <p>once I auto loaded the helper and called this function in my controller as:</p>
  
  <p><strong>My_controller.php</strong>:</p>
  
  <pre><code>public function index() {
      count_hits();
      //index code here
  }
  </code></pre>
  
  <p>The problem is that I am getting a blank page and other codes does not run I think. What am I doing wrong?!</p>