Welcome Guest, Not a member yet? Register   Sign In
displaying blob data from db
#1

[eluser]junaids[/eluser]
Hi,
I am trying to display data from data base but getting an error. my function is,
<?php
Code:
function getpic($id){

     $query = $this->db->query("SELECT content FROM picture WHERE id = '$id';");
     if($query){
        $result = $query->result();
        foreach($result as $result){
           header("Content-type: image/jpg");
           print $result->$field;
        }
     }

}
}

my url is..
http://localhost/codeigniter32/index.php/shop/getpic/1
and i am getting the error
The image “http://localhost/codeigniter32/index.php/shop/getpic/1” cannot be displayed because it contains errors.

The url in this error points correctly to the controller and function ..any help????
#2

[eluser]Bhashkar Yadav[/eluser]
you need to set header for displaying image content like
Code:
header("Content-type: image/jpeg");

instead of

Code:
header("Content-type: image/jpg");
#3

[eluser]vitoco[/eluser]
i don't know where i's defined the $field var , so this
Code:
print $result->$field;
i think should be
Code:
print $result->content;

Saludos
#4

[eluser]junaids[/eluser]
@vitoco..ur advice works fine.




Theme © iAndrew 2016 - Forum software by © MyBB