Reading BLOB content in phpmyadmin

    Question by:
    On

    Topics:

    One of the fields in a database that I am working with in phpMyadmin has content in BLOB format. I want to read what this content is and browse it. But phpMyadmin doesn't display the content. So what should I do? I changed the settings in config.ini.php to
    $cfgShowblob              = TRUE;
    but doesnt that seem to have changed anything? (do i need to do something to make the changes in config.ini.php take effect?)
    i know i can also dump the db thru ssh but i am having trouble doing that so I would like a solution that doesnt involve doing that.

    Good Question?
    0
     

    ?

    The member who asked this question verified this comment provided the solution that solved their problem.

    Accepted Solution on 2008-01-17 at 12:34:12ID: 20685081

    blob data stands for "binary large object". It can be used to store binary data such as pictures, music, executables, etc. (Anything that is binary)

    If you could see the binary data in an editor, it would look like a bunch of garbled junk text.

    The way you read it is using a sql query to extract it from the database, then add a correct header, then output it to the browser.

    <?php
     
    // create a db connection
    @mysql_connect('localhost', 'db_username', 'db_password') or die(mysql_error());
    @mysql_select_db('database_name') or die(mysql_error()); 
     
    $result = @mysql_query('SELECT blob_data FROM table') or die(mysql_error());
    while ($row = mysql_fetch_array($result))
    {
    	// change this header to the proper mime type
    	header("Content-type: image/jpeg"); 
    	echo $row['content'];
    }
     
    ?>
    
                                            
    1:
    2:
    3:
    4:
    5:
    6:
    7:
    8:
    9:
    10:
    11:
    12:
    13:
    14:
    15:
    

    Select allOpen in new window

    Top Expert Contributor

    Essential articles and videos from the Experts

    More valuable questions with Expert answers

    201511-LO-Qu-074

    Extend your technology team with the Experts Exchange community.

    — trusted by —

    Who answers my questions?Our community has technology experts around the world.

    Ray Paseur

    47

    Articles

    13,942

    Solutions

    Expert in:

    • PHP
    • MySQL Server
    • Web Development
    • HTML
    • JavaScript

    Dave Baldwin

    10,942

    Solutions

    Expert in:

    • PHP
    • CSS
    • HTML
    • MySQL Server
    • Web Development

    BigRat

    2,293

    Solutions

    Expert in:

    • Math / Science
    • XML
    • ASP
    • Apache Web Server
    • Delphi

    Chris

    20

    Solutions

    Vimal DM

    118

    Solutions

    Expert in:

    • PHP

    Marco Gasi

    5

    Articles

    1,060

    Solutions

    Expert in:

    • PHP
    • CSS
    • HTML
    • JavaScript
    • MySQL Server

    Steve Bink

    3,524

    Solutions

    Expert in:

    • MS Access
    • PHP
    • Apache Web Server
    • MySQL Server
    • Web Development

    William Nettmann

    58

    Solutions

    Expert in:

    • WordPress

    Mark Brady

    1

    Articles

    628

    Solutions

    Expert in:

    • PHP
    • HTML
    • JavaScript
    • MySQL Server
    • Scripting Languages

    RELATED TOPICS view all topics

    1. MySQL Server
      (45,797)
    2. JavaScript
      (117,333)
    3. Web Development
      (72,046)
    4. HTML
      (56,051)
    5. Apache Web Server
      (19,917)
    6. Web Languages/Standards
      (39,422)
    7. WordPress
      (7,932)
    8. Scripting Languages
      (25,831)
    9. AJAX
      (11,837)
    10. Web Applications
      (14,208)