0
 function getImage()
    {
        $session_data = $this->session->userdata('sessiondata');
        $id = $session_data['user_id'];
        $this->db->where('user_id',$id);
        $r=$this->db->get('tbl_usrs');
        if($r->num_rows()>0)
        {
            foreach ($r -> result_array() as $row) {
            $data[] = $row;
            }
        }
        $r->free_result();
        return $data;
        //print_r($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...
cotroller

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";
            $this->load->model('Display_profilepicture');
            //echo '<br>'."hm";
            $data = $this->Display_profilepicture->getImage();
            //echo '<br>'."hmmmm";
            //echo count($data);
            //print_r($data);//nothing printed
            //$img="some";
            $data['profile_picture']=array('profile_picture'=>$img);
            //print_r( $data);
            //header("Content-type: image/jpg");
            $this->load->view('my_profile',array('data'=>$data));



            }
         any help will be appreciated

//model

2
Contributors
1
Reply
15
Views
2 Years
Discussion Span
Last Post by cereal
1

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.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.