function getImage()
        $session_data = $this->session->userdata('sessiondata');
        $id = $session_data['user_id'];
            foreach ($r -> result_array() as $row) {
            $data[] = $row;
        return $data;
    }} //class ends     

hello everone i am new to php codeigniter while displaying image from database i am getting error Severity: Notice

Message: Undefined variable: img

don't know why error is...

public function index() {
            if($this->session->userdata('is_login')) {
            $session_data = $this->session->userdata('sessiondata');
            $id = $session_data['user_id'];
            //$img = $session_data['profile_picture'];
            //echo $img;
            //echo "hahahahaaaaaaaaa";
            //echo '<br>'."hm";
            $data = $this->Display_profilepicture->getImage();
            //echo '<br>'."hmmmm";
            //echo count($data);
            //print_r($data);//nothing printed
            //print_r( $data);
            //header("Content-type: image/jpg");

         any help will be appreciated


The error is generated by line 15:

 [5] //$img = $session_data['profile_picture'];
[15] $data['profile_picture']=array('profile_picture'=>$img);

You're using an undefined variable $img, which is commented at line 5.