Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New Coder
    Join Date
    Mar 2012
    Posts
    33
    Thanks
    1
    Thanked 1 Time in 1 Post

    Displaying BLOB Help

    I have an image saved inside the database as a BLOB data type but I'm having trouble displaying it on the page.
    Here is my code:
    PHP Code:
    if(isset($_GET['id']))
    {
        
    mysql_connect("127.0.0.1","root","");
        
    mysql_select_db("test");
        
        
    $id $_GET["id"];
        
    $query mysql_query("SELECT * FROM `blob` WHERE `id`='$id'");
        while(
    $row mysql_fetch_assoc($query))
        {
            
    $imageName $row["name"];
            
    $imageData $row["image"];
        }
        
    header("content-type: image/jpeg");
        echo 
    $imageName."<br />".$imageData;

    All I see if a little square box in the very top left.
    Can somebody tell me what I did wrong.
    Thanks in advance.

  • #2
    Regular Coder patryk's Avatar
    Join Date
    Oct 2012
    Location
    /dev/couch
    Posts
    398
    Thanks
    2
    Thanked 64 Times in 64 Posts
    you put text in your image.
    should be
    Code:
    echo $imageData;
    if you set mime type to image/jpeg how do you expect it to be displayed if you mix it with html?

  • #3
    New Coder
    Join Date
    Mar 2012
    Posts
    33
    Thanks
    1
    Thanked 1 Time in 1 Post
    Still nothing. Any other suggestions?

  • #4
    Regular Coder patryk's Avatar
    Join Date
    Oct 2012
    Location
    /dev/couch
    Posts
    398
    Thanks
    2
    Thanked 64 Times in 64 Posts
    show output of your script

  • #5
    New Coder
    Join Date
    Mar 2012
    Posts
    33
    Thanks
    1
    Thanked 1 Time in 1 Post
    Never mind I got it to work now.
    Thanks anyway.

  • #6
    Regular Coder patryk's Avatar
    Join Date
    Oct 2012
    Location
    /dev/couch
    Posts
    398
    Thanks
    2
    Thanked 64 Times in 64 Posts
    say how you did it. might help others


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •