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

[eluser]junaids[/eluser]
I am trying to display data from data base but getting an error. my controller is,
Code:
<?php

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
Code:
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]junaids[/eluser]
i used CI 2 yrs back...and i faced same problem..cudnt display pix...
now 2 yrs fast forward..same problem...Sad
#3

[eluser]Unknown[/eluser]
try this,

Code:
<img src="view_image_action" alt="Image from DB" height="600" width="700"/>



This is the view_image_action contoller
Code:
$sql = "SELECT img,name,type FROM images WHERE id=2";
$query = mysql_query("$sql") or die("Invalid query: " . mysql_error());
$row = mysql_fetch_array($query);
$content = $row['img'];
header("Content-type:image/jpeg");
print $row['img'];
#4

[eluser]CroNiX[/eluser]
You are overriding your original variable here...
Code:
foreach($result as $result){




Theme © iAndrew 2016 - Forum software by © MyBB