Page 1 of 1

image retrieving from mysql problem

Posted: Mon Nov 15, 2010 3:44 am
by strazdinjsh
That must be very simple but i can not step over the issue what i have got.
1. i have file which displays the image called index.php with source code of
--------------------------------------------------------------------
...
<img src="sample.php?id=42" />
...
--------------------------------------------------------------------
2. then i have file sample.php with source code
-------------------------------------------------------------------------------------
require("sys/functions.php");
dbConnect();
$id = $_GET["id"];
if(!isset($id))
{
echo "select an ID";
}
else
{
$res = mysql_query("SELECT * FROM gallery where id=$id");
$row = mysql_fetch_assoc($res);

header("Content-type: image/$row[extension]");
echo $row['image'];
}

-------------------------------------------------------------------------------------------
3. i have successfully uploaded file to MySQL, i can see it as a record with id=42 (image - that is the actual file, extensions - image extension)
4. when launching the index.php i am not getting an image but still can get a file size, approx. must be right 248kb. image itself does not display

Could anyone have a look and give me some idea to start with... thanks a lot.

Re: image retrieving from mysql problem

Posted: Mon Nov 15, 2010 9:13 am
by AbraCadaver

Code: Select all

error_reporting(E_ALL);
ini_set('display_errors', '1');