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

    Open in new window

    verified

    answer

    Enjoy your free answer!

    Join now to get more tech resources.

    Become a member

    Comments

      

    Accepted Solution

    2008-01-17 at 12:34:12ID: 20685081Best
    ray-solomon earned 500 total points
    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

    Good Solution?
    0

    Featured Post

    Course: AWS Professional Certification

    These classes are designed to help you pass the AWS Certified Solutions Architect – Associate, AWS Certified Developer, and AWS Certified SysOps Administrator Associate exams—all essential to a career as an AWS professional.

    Ask Your Tech Question. Get Expert Solutions.We will email you as soon as we have your answer.

    We will never share this with anyone.

    Select topics

    You may select up to five topics.

    Top Expert Contributor

    Essential articles and videos from the Experts

    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…
    Both Easy and Powerful How easy is PHP? http://lmgtfy.com?q=how+easy+is+php (http://lmgtfy.com?q=how+easy+is+php)  Very easy.  It has been described as "a programming language even my grandmother can use." How powerful is PHP?  http://en.wikiped…
    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 count occurrences of each item in an array.

    More valuable questions with Expert answers

    Question: I have a set of forms (PHP) that save/retrieve data from a MySQL database. Once you input the data and it is saved to the database, you can leave and come back as a returning client later. To do this you login with a username and password as a...

    Answer: We do not send the PASSWORD and USERNAME variable from one page to another page. That is the sort of faulty design that leads to security exposures, so just don't do that. Instead, please step back from the implementation details of a bad design...

    PHP

    Question: I found some cool code that is meant to validate the date in dd/mm/yyyy format and also check that the day of the month actually exists i.e.: you can't type in 31/02/2016. But even if I put in a perfectly valid date it still throws the error that...

    Answer: Strange, for me it works: (CODE) See it here: http://test.webintenerife.com/check_date.php

    PHP

    Question: (CODE) I am running xampp on a windows system Above code: The actual root to the uploads directory is as follows: c:\xampp\htdocs\Development\dev\Uploadify\uploads Or http://localhost:888/Development\dev\Uploadify\uploads It has the...

    Answer: Check your settings about upload limitations: http://www.php.net/manual/en/ini.core.php#ini.file-uploads Bye, Olaf.

    Question: I've got a database with a life of mp3 file names. I want to go through that database, pick the mp3 file from the directory it resides in and move it to another directory. I've seen PHP move_uploaded_file, but I can't tell where the starting...

    Answer: Moving files in PHP is done with the rename function (http://php.net/manual/en/function.rename.php).(CODE)

    PHP
    201607-LO-Qu-086

    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

    14,555

    Solutions

    Expert in:

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

    Dave Baldwin

    1

    Articles

    11,471

    Solutions

    Expert in:

    • PHP
    • CSS
    • HTML
    • JavaScript
    • MySQL Server

    Guy Hengel [angelIII / a3]

    11

    Articles

    37,329

    Solutions

    Expert in:

    • MS SQL Server
    • MS SQL Server 2005
    • Databases-Other
    • MS SQL Server 2008
    • MySQL Server

    zephyr_hex

    2,676

    Solutions

    Expert in:

    • MS SharePoint
    • MS SQL Server 2005
    • Microsoft IIS Web Server
    • Windows Server 2003
    • Windows XP

    gr8gonzo

    19

    Articles

    1,317

    Solutions

    Expert in:

    • PHP
    • MySQL Server
    • Apache Web Server
    • Web Development-Other
    • HTML

    lenamtl

    658

    Solutions

    Expert in:

    • JavaScript
    • Joomla
    • PHP
    • Web Development-Other
    • Web-Based CMS

    Olaf Doschke

    2

    Articles

    1,376

    Solutions

    Expert in:

    • FoxPro
    • MS SQL Server
    • MS SQL Server 2008
    • .NET Programming
    • Databases-Other

    Jim Dettman (Microsoft MVP/ EE MVE)

    7

    Articles

    5,566

    Solutions

    Expert in:

    • MS Access
    • MS Applications
    • Databases-Other
    • MS Development-Other
    • MS Office

    Sharath

    2,396

    Solutions

    Expert in:

    • MS SQL Server 2005
    • Query Syntax
    • MS SQL Server
    • MS SQL Server 2008
    • Databases-Other

    RELATED TOPICS view all topics

    1. MySQL Server
      (46,025)
    2. JavaScript
      (118,127)
    3. Web Development-Other
      (72,548)
    4. HTML
      (56,628)
    5. Apache Web Server
      (19,495)
    6. Web Languages/Standards-Other
      (39,384)
    7. WordPress
      (8,179)
    8. Scripting Languages
      (26,214)
    9. AJAX
      (11,978)
    10. Web Applications
      (13,942)
    Receive Monthly Emails of Tech News and Trends from Experts Exchange