PHP/Mysql image problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • EVAS
    New Member
    • Nov 2007
    • 8

    PHP/Mysql image problem

    hello there! i got a question about blob mysql data.i have a button and on buttonclick i want to open a popup (and passing date parameter) and show some details and display a photo.if i try
    Code:
    <?php
    if (isset($_GET['p'])){
       $temp_date=$_GET['p'];
       echo "DATE : $temp_d <br>";
       $date_m=date('Y-m-d',strtotime($d));
       $connect=mysql_connect("localhost","user","pass")
       or die ("Check your server connection"); 
       $db_found = mysql_select_db("mydb", $connect);
       $SQL = "SELECT * FROM mytable
               WHERE date =date_m";
               $result = mysql_query($SQL);
               $row=mysql_fetch_array($result);
               echo "Details: $row[details]<br>";
               $content = $row['image'];
               header('Content-type:image/jpg');
               echo $content;       
    } ?>
    its not working.if i try
    Code:
    <?php
       $connect=mysql_connect("localhost","user","pass")
       or die ("Check your server connection"); 
       $db_found = mysql_select_db("mydb", $connect);
       $SQL = "SELECT * FROM mytable
               WHERE id=1";
               $result = mysql_query($SQL);
               $row=mysql_fetch_array($result);
               echo "Details: $row[details]<br>";
               $content = $row['image'];
               header('Content-type:image/jpg');
               echo $content;       
    } ?>
    its shows my results.how to pass the parameter and show the results to ? and does anybody knows why it doesnt work with parameter passing ? tnx in advance
  • johny10151981
    Top Contributor
    • Jan 2010
    • 1059

    #2
    First of all you need to modify the header content-type. follow the link, you will get lots of valuable information

    2. do not echo or any data, not even a blank space from the file that retrive and send image to browser. you did on line 4

    Comment

    • EVAS
      New Member
      • Nov 2007
      • 8

      #3
      thx for reply! i did it and the image is displayed! but how can i add some text? tnx in advance

      Comment

      • johny10151981
        Top Contributor
        • Jan 2010
        • 1059

        #4
        two solution
        1. embed the image with base 64 encoding
        2. create a temporary image file and print the image path in image tag.

        Comment

        Working...