Php getting image from BLOB

Hello, I have little problem with displaying image from mysql base.
I have this code to insert image into (Working, images are stored in database as expected)

if (isset($_POST["image"]) && $_POST["image"]=="TRUE"){
$image = addslashes(file_get_contents($_FILES['image']['tmp_name']));
$imagen= addslashes($_FILES['image']['name']);
$images = getimagesize($_FILES['image']['tmp_name']);
if ($images==FALSE){
  echo "That's not an image.";
if  (!$insert=mysql_query("INSERT INTO avatars VALUES ('','$sesja','$imagen','$image')")){
  echo "Problem uploading image.";
echo "<img src=get.php?user=$sesja>";

and in get.php file I have got :

  $image=mysql_query("SELECT * FROM avatars WHERE login=$user");
  header("Content-type: image/jpeg");
  echo $image;

And the result is image that indicates damaged pic, don’t know whats wrong, everything seems fine to me:(
Obviously $sesja is declared above.
@edit: changed first line so the hidden input has different name.

Remove addslashes from the following line and try again

$image = addslashes(file_get_contents($_FILES['image']['tmp_name']));

ps. addslashes is not the proper way to escape strings. Use prepared statements instead.
ps2. You should better store images to filesystem and paths in database.

Without addslashes it does not upload the image at all.
I have access to images via database, so I guess there is something wrong with get file or with the img src display method:l

You could use base64 functions to encode/decode file’s content. You could also replace addslashes with prepared statements.

ps. Storing images in database is not a good solution. You should better store images to filesystem and paths in database.

Yes I know it is better to store images to filesystem however in this project I have to use BLOB table…:frowning:
Replaced addslashes and doing it with base64 function however another error occurs with my get.php file

$result = mysql_query("SELECT image FROM avatars WHERE id=8);
if (mysql_num_rows($result) != 0)
$row = mysql_fetch_assoc($result);
echo ($row['image']);

Error: Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING.