I am displaying the image stored in database. The problem what i am facing is, the image displayed is truncated and only the partial image is shown. Then if i makes request to another page(php page), then instead executing the php page the browser displays the download page pop up. On downloading the php script page, the page if opened in text editor, shows some unreadable ( in red color) text (probably the truncated image content) and then proper php script. Following is the snapshot of page downloaded [COLOR="Red"]Q@Q@Q@Q@Q@Q@Q@Q@Q@QQ@Q@Q@Q@Q@Q@Q@Q@Q@Q@Q@ Q@Q@Q@Q@Q@Q@Q@Q@QQ@Q@Q@Q@Q@Q@Q@Q@Q@Q@ÿÙ[/COLOR] [COLOR="RoyalBlue"]HTTP/1.1 200 OK Date: Thu, 30 Aug 2007 07:11:09 GMT Server: Apache/2.2.4 (Win32) PHP/5.2.3 X-Powered-By: PHP/5.2.3 Expires: Thu, 19 Nov 1981 08:52:00 GMT Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0 Pragma: no-cache Content-Length: 523 Keep-Alive: timeout=5, max=98 Connection: Keep-Alive Content-Type: text/html [/COLOR] [COLOR="Black"]<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title> Welcome to the Network</title> <link rel="stylesheet" type="text/css" href="css/winxp.blue.css"/> </head> <body> <div class="screenLayout"> <div class="headerContainer"> <div class="pageHeader"> </div> </div> <div align="right"> <a href="logout.php"> Logout</a> </div><h3>Successfully logged Out.</h3> <h2> <a href="index.php"> Login again</a></h2> </body> </html> [/COLOR] Code (markup): The page which fetches the image from database is <?php //getImage.php function __autoload($class_name) { require_once $class_name . '.php'; } ?> <?php $photo_id=$_REQUEST["photo_id"]; ?> <?php session_start(); $authorized = false; $loggedUser = $_SESSION["LOGGED_USER"]; if ($loggedUser == null) { header('Location: index.php') ; } else { $authorized = true; } $photo_id=$_REQUEST["photo_id"]; ?> <?php if ($authorized) { require_once("dbConnection.php"); $con = getConnection(); //flush(); $selectPhotoQuery = "select * from photos where photo_id=".$photo_id; $resultSet = mysql_query($selectPhotoQuery) or die("Error: coud not select image"); $recordSelected = mysql_numrows($resultSet); if ( $recordSelected == 1) { $row = mysql_fetch_array($resultSet); $fileSize = $row["file_size"]; $fileType = $row["file_type"]; $fileImageContent = $row["photo_blob"]; } else { //default image $defaultFileName = "img/default.jpg"; $fp = fopen($defaultFileName, 'r'); $fileSize = filesize($defaultFileName); $fileImageContent = fread($fp, $fileSize); $fileType = "image/jpeg"; //$fileImageContent = addslashes($fileImageContent); fclose($fp); } mysql_close($con); [COLOR="Lime"]header("Content-type: ".$fileType); header("Content-length: ".$fileSize); echo $fileImageContent;[/COLOR] exit(); } else { header("Location: index.php"); } ?> Code (markup): And the image is displayed as <?php echo "\n<[COLOR="Blue"]img src='getImage.php?photo_id=[/COLOR]".$loggedUser->getUserPhotoId()."' width='100' height='100' border='1'>"; ?> Code (markup):