Solved

Reading BLOB content in phpmyadmin

Posted on 2008-01-16
9,887 Views
Last Modified: 2013-12-12
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.
0
Question by:Igiwwa
    1 Comment
     
    LVL 10

    Accepted Solution

    by:
    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'];
    
    }
     
    
    ?>
    

    Open in new window

    0

    Write Comment

    Please enter a first name

    Please enter a last name

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

    Featured Post

    Course: MongoDB Object-Document Mapper for NodeJS

    NodeJS (JavaScript on the server) is awesome, but some developers get confused about NoSQL when it comes to working in Node with MongoDB (NoSQL database). Do you need a better explanation of how to use Node.js with MongoDB? The most popular choice is the Mongoose library.

    This is a general how to create your own custom plugin system for your PHP application that you designed (or wish to extend a third party program to have plugin functionality that doesn't have it yet).  This is not how to make plugins for existing s…
    Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
    Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
    The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

    659 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    28 Experts available now in Live!

    Get 1:1 Help Now