Member Avatar for anmol.raghuvanshi1

I get sick in finding error in my code i want to display a image from database having field profile_picture which has value like upload/large/imagename.jpg but i can't able to display it main thing is nothing is printed when i echo or print from controller
when i view page source it shows <img title="profile image" src="http://localhost/ko/Display_profilepic/index">
don't where i am getting wrong

controller Display_profilepic

<?php
if ( ! defined('BASEPATH')) exit('No direct script access allowed');

ini_set("display_errors",1);

class Display_profilepic extends CI_Controller {

public function __construct()
{
   // Call the Model constructor
   parent::__construct();
   $this->load->library('session');
   $this->load->database();
   $this->load->helper('html');
   $this->load->helper(array('form', 'url'));
   $this->load->model('Display_profilepicture'); 


}
public function index() {
        if($this->session->userdata('is_login')) {
        $this->load->model('Display_profilepicture');
        $data = $this->Display_profilepicture->getImage();
        print_r($data);//nothing printed
        $data=array('profile_picture'=>$img);
        $this->load->view("my_profile",$data);



        }


}




}// class ends 

?>

model Display_profilepicture

<?php
if ( ! defined('BASEPATH')) exit('No direct script access allowed');

ini_set("display_errors",1);

class Display_profilepicture extends CI_Model {

function __construct()
{
          // Call the Model constructor
          parent::__construct();
          $this->load->library('session');
           $this->load->database();
          //$this->file_path = realpath(APPPATH . '../upload/large');
         // $this->file_path_url = base_url().'upload/large/';
          //$this->is_login();
          //$this->load->helper(array('form', 'url'));
}
function getImage()
    {
        $id = $this->session->userdata('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;
    }} //class ends     
?>

when i try to change the name model in my controller to see what happens no error is displayed like undefined property.

Member Avatar for anmol.raghuvanshi1

Now stepping forward now some errors are been displayed undefined variable $data in model and $img in controller

Member Avatar for anmol.raghuvanshi1

Can any one help me

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.