Reading BLOB content in phpmyadmin

    Question by:


    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.

    // 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'];

    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


    RELATED TOPICS view all topics

    1. MySQL Server
    2. JavaScript
    3. Web Development
    4. HTML
    5. Apache Web Server
    6. Web Languages/Standards
    7. WordPress
    8. Scripting Languages
    9. AJAX
    10. Web Applications