can't display image from database

Discussion in 'PHP and MySQL' started by stelios, Jan 29, 2012.

  1. stelios

    stelios Guppy

    Hello,

    I have uploaded some pictures in my database, but when I retrieve them they are not displayed. The rest of the information is well appeared.

    This is my image.php file:
    PHP:
    <?php

    include ('dbconnect.php');
    $db connect();
    $id=$_REQUEST['id'];
    $stmt $db->query('select name,type,content from upload where id='.$id);
    foreach(
    $stmt as $row)
    {
    echo 
    $row['name'].' '.$row['type'];
        
    $imagebytes $row['content'];

    header("Content-type: "$row['type']);

    print 
    $imagebytes;

    }

    ?>
    and then in my html i call it by:
    <img src="image.php?id=1">

    Where is my mistake? Thanks in advance
  2. linda martin

    linda martin Guppy

    The image link is wrong.You will change the link and connect the database.You retrieve the program and then execute.

Share This Page

JodoHost - 26,000 hosting end-users in 100 countries
Plesk Web Hosting
VPS Hosting
H-Sphere Web Hosting
Other Services