hi everyone

i want to insert and retrieve images from the mysql using php(in wamp server).actually i searched the net and tried with many codes but cudnt find a solution.in the last one tht i tried,i created a table tht includes a blob datatype for one of its attribute and also an id that is auto incremented.i insert it normally using the insert statement.similarly for retrieving i assing the retrieved one to an <img src> but cudnt find anything working.then i opened the database and directly inserted an image to it.then while retrieving i cud see only a small icon like thing in the front end.when i tried to open it, i cudnt.can someone help me with this/
thanks in advance

9 Years
Discussion Span
Last Post by mhariharasudan

hi josh.
thanks for ur reply.i tried that in my code.but there i redirected that to someothe page and retrieved the id there and got its value using 'get' function and there i selected the header type.here is my piece of code.ill try the code which u directed to me and let u know.

  include 'db.inc';

  $file = clean($file, 4);

  if (empty($file))

  if (!($connection = @ mysql_pconnect($hostName,

  if (!mysql_select_db("files", $connection))

  $query = "SELECT mimeType, fileContents FROM files 
            WHERE id = $file";

  if (!($result = @ mysql_query ($query,$connection)))

  $data = @ mysql_fetch_array($result);

  if (!empty($data["fileContents"]))

     header("Content-Type: {$data["mimeType"]}");

     echo $data["fileContents"];

i connected the database in db.inc

Edited by pritaeas: Fixed formatting

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.