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.

     

    Verified Answer?

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

    by:Posted 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

    This content is available to Experts Exchange members

    See the answer now
    with your Free 30 Day Trial

    Get unlimited access to solutions & experts

    • 4,169,477 solved questions
    • 3,805 articles & videos
    • 15,413 tech experts

    Get Access Now

    Ask Your Tech Question. Get Expert Solutions.We will email you when an expert has commented on your question.

    We will never share this with anyone. Privacy Policy Terms of Use

    Select topics

    You may select up to five topics.

    Top Expert Contributor

    Essential articles and videos from the Experts

    More valuable questions with Expert answers

    201508-LO-Qu-072

    RELATED TOPICS view all topics

    1. MySQL Server
      (45,359)
    2. JavaScript
      (116,295)
    3. Web Development
      (70,768)
    4. HTML
      (55,262)
    5. Apache Web Server
      (19,695)
    6. Web Languages/Standards
      (39,262)
    7. WordPress
      (7,484)
    8. Scripting Languages
      (25,472)
    9. AJAX
      (11,656)
    10. Web Applications
      (14,044)