php database image show problem

Posted by Termedi on Stack Overflow See other posts from Stack Overflow or by Termedi
Published on 2010-04-05T07:50:40Z Indexed on 2010/04/05 7:53 UTC
Read the original article Hit count: 206

Filed under:
|

here is the code

<?php
 session_start();

 if(!isset($_SESSION['user_name']))
 {
  header('Location: login.php');
 }

 $conn = mysql_connect("localhost", "root", "") or die("Can no connect to Database Server");
?>

<html>
<head>

</head>
<body>
<center>
<div id="ser">
<form action="" method="post">


<label for="file">Card No:</label>
<input type="text" name="card_no" id="card_no" class="fil" onKeyUp="CardNoLength()" onKeyDown="CardNoLength()" onKeyPress="CardNoLength()"/>
<input type="submit" name="search" value="Search" class="btn" onClick="return CardNoLengthMIN()"/>
</form>
</div>
</center>
<br/><hr style="border: 1px solid #606060 ;" />
<center><a href="index.php">Home</a></center>
<br/>

<center>
<?php

 if(isset($_POST['card_no']))
 {
  if($conn)
  {
   if(mysql_select_db("img_mgmt", $conn))
   {
    $sql = "select * from temp_images where card_no='".trim($_POST['card_no'])."'";
    $result = mysql_query($sql);
    $image = mysql_fetch_array($result);

    if(isset($image['card_no']))
    {

      //echo "<img src=\"".$image['file_path']."\" alt=\"".$image['card_no']."\" width=\"250\" height=\"280\"/>";
      header("Content-type: image/jpeg");
      echo $image['img_content'];

    }
    else
    {
      echo "<p style=\"color:red;\">Sorry, Your search came with no results ! <br/> Try with different card number";
    }
   }
   else
   {
    echo "Database selection error: ".mysql_error();
   }
  }
  else
  {
   echo "Could not connect: ".mysql_error();
  }
 }
?>
</center>

</body>
</html>

But it after executing the script it shows:

Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\img\search.php:61) in C:\xampp\htdocs\img\search.php on line 77

© Stack Overflow or respective owner

Related posts about php

Related posts about mysql