Solved

Reading BLOB content in phpmyadmin

Posted on 2008-01-16
1
10,029 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
Comment
Question by:Igiwwa
1 Comment
 
LVL 10

Accepted Solution

by:
ray-solomon earned 500 total points
ID: 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

0

Featured Post

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

773 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