img display from mysql database needs help

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • tolkienarda
    Contributor
    • Dec 2006
    • 316

    #1

    img display from mysql database needs help

    hi all

    I have this script that i found and modified slightly it appears to use some code i am not famalier with so trouble shooting has turned into a night mare but here is what i have

    this part is on my page where i want the image displayed
    [HTML]
    <img src="imagedisp. php?title=asdf" >
    [/HTML]

    here is the imagedisp.php page

    [PHP]

    $result = "SELECT imgdata, type FROM pix WHERE title='$title'" ;
    $Show = mysql ( $hDB, $hSQL );
    $rows = mysql_num_rows( $hShow);

    if($rows<1){
    // no image matches this query
    }
    else{
    // at least one image has this title
    $getPhoto = mysql_fetch_obj ect($Show);

    // we need to determine the mime type
    $Type = $getPhoto->type;

    // and send the correct header to the browser
    Header("Content-type: $Type");

    // now send the image
    $Body = $getPhoto->body;
    echo $Body;
    flush();
    }
    [/PHP]

    thanks for any guidence

    eric
  • cassbiz
    New Member
    • Oct 2006
    • 202

    #2
    Originally posted by tolkienarda
    hi all

    I have this script that i found and modified slightly it appears to use some code i am not famalier with so trouble shooting has turned into a night mare but here is what i have

    this part is on my page where i want the image displayed
    [HTML]
    <img src="imagedisp. php?title=asdf" >
    [/HTML]

    here is the imagedisp.php page

    [PHP]

    $result = "SELECT imgdata, type FROM pix WHERE title='$title'" ;
    $Show = mysql ( $hDB, $hSQL );
    $rows = mysql_num_rows( $hShow);

    if($rows<1){
    // no image matches this query
    }
    else{
    // at least one image has this title
    $getPhoto = mysql_fetch_obj ect($Show);

    // we need to determine the mime type
    $Type = $getPhoto->type;

    // and send the correct header to the browser
    Header("Content-type: $Type");

    // now send the image
    $Body = $getPhoto->body;
    echo $Body;
    flush();
    }
    [/PHP]

    thanks for any guidence

    eric
    Shooting in the dark here, but hope it helps,

    Code:
    <img src="<?php include=imagedisp.php?title=asdf ?>" />
    you have to be sure that the output is still an image (jpg, gif, png, etc...)

    Comment

    • cassbiz
      New Member
      • Oct 2006
      • 202

      #3
      oops wrote the include statement wrong.

      Code:
      <img src="<?php include imagedisp.php?title=asdf; ?>" />

      Comment

      • tolkienarda
        Contributor
        • Dec 2006
        • 316

        #4
        Originally posted by cassbiz
        oops wrote the include statement wrong.

        Code:
        <img src="<?php include imagedisp.php?title=asdf; ?>" />
        thanks i will give it a shot and get back to you if it works or not

        eirc

        Comment

        Working...