Controller: I'm trying to fetch the records from database, but it is showing undefined variable $data in the view section. What is the problem i don't understand.
public function vabout(){
    if(!$this->session->userdata('logged_in')){
        redirect('register/login');
    }
    $this->load->model('profile_model');
    $data = $this->profile_model->viewprofile();
    $this->load->view('templates/pheader');
    $this->load->view('profile/viewabout',$data);
    $this->load->view('templates/pfooter');
}
Model: This is the model section, is there any issue in model for fetching the record?
public function viewprofile(){
    $data = $this->db->get('profile');
    return $data->row_array();
}
View: errore: a php error encountered $data is undefined
<?php
      foreach ($data as $row)
        { ?>
        <p><?php echo $row->id; ?></p>
        <p><?php echo $row->name; ?></p>
        <?php
      }
  ?>
 
     
    