image displaying problem php

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • vikidigi
    New Member
    • Jul 2007
    • 7

    #1

    image displaying problem php

    PLz Help
    i have some Images in DataBase in Blob field
    but images are displayed with a Cross (X) not the actual image

    MainPage.php//code

    [code=php]
    # <?php
    # $con = mysql_connect(" localhost","roo t","");
    # if (!$con)
    # die('Could not connect: ' . mysql_error());
    # mysql_select_db ("db1", $con);
    # $image = mysql_query("SE LECT * FROM userimagetable" );
    # while($imageRes ult = mysql_fetch_arr ay($image) ){
    # ?>
    # <img src="ViewImage. php?id=<?=$imag eResult['id']?>" alt="Picture" /></td></tr>
    # <?php
    # }
    #
    # and the other file displaying image code is
    #
    # ViewImage.php
    # <?php
    # $id = $_GET['id'];
    # $image = mysql_query("SE LECT * FROM userimagetable WHERE Id='".$id."'");
    # $imageResult = mysql_fetch_arr ay($image);
    # header("Content-type: image/jpg");
    # echo $imageResult['UserImage'];
    # ?>
    [/code]
  • Markus
    Recognized Expert Expert
    • Jun 2007
    • 6092

    #2
    I'll hazard a guess and say you're not setting the correct content-type?

    What happens is you try and go to ViewImage.php?i d=someid (substituting someid for a valid id)?

    Comment

    • vikidigi
      New Member
      • Jul 2007
      • 7

      #3
      i have removed the header for the file
      [code=php]
      <?php
      $con = mysql_connect(" localhost","roo t","");
      if (!$con)
      die('Could not connect: ' . mysql_error());
      mysql_select_db ("image", $con);
      //header('Content-type: image/jpeg');
      $query = "SELECT image from images where id=1";
      $rs = mysql_fetch_arr ay(mysql_query( $query));
      echo base64_decode($ rs["image"]);
      [/code=php]

      Comment

      • vikidigi
        New Member
        • Jul 2007
        • 7

        #4
        all images are only jpg in database

        Comment

        • Markus
          Recognized Expert Expert
          • Jun 2007
          • 6092

          #5
          Like I said, what happens when you visit the page that displays the image. Note: not the image tag, the actual image serving page.

          Comment

          • vikidigi
            New Member
            • Jul 2007
            • 7

            #6
            Displaying image from database

            and displays image region in a square with a red Cross {X} in the image area
            and not displaying the actual image

            Comment

            • vikidigi
              New Member
              • Jul 2007
              • 7

              #7
              the page is error free


              contents of the page are

              "
              Displaying image from database
              Image [with Cross]
              "

              Comment

              Working...