hello all
I have managed to write my very own image upload script. Image will be uploaded to a dir, and image info will be uploaded to MySQL database. Everything seems fine so far...

The problem comes when i try to display image. Like say i click on an image link (EX. http://www.yaya.com/image.php?id=25), i couldn't view the image, just a broken image.


Here is my entire image.php script
PHP Code:
<?php php_track_vars?>
<?php
if(!isset($Id))
{
    die(
"Need 'Id' parameter");
} else
{
    
$Id=addslashes($Id);
}

include(
"common.php");


//set up SQL connection
    
$link mysql_connect ($., $., $.);
        if (! 
$link)
            {
            die (
"Couldn't connect to mySQL server");
            }
        if (!
mysql_select_db ($db$link) )
            {
            die (
"Coldn't open $db: ".mysql_error() );
            }


$query "SELECT * FROM tbl_Files WHERE id_files='$Id';";
$result mysql_query($query);
    

$query_data mysql_fetch_array($result);
$filetype $query_data[filetype];


$photo=str_replace('$dir','',$binFile);

echo 
"<img src='$photo'>";

?>


Can somebody lead me to the right direction? is this the right way to pull/display image from the directory? Please help

thank you