php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #50467 Displaying multiple images, BLOB data, from a MySQL database
Submitted: 2009-12-13 19:59 UTC Modified: 2009-12-13 20:07 UTC
From: businessitconsulting at yahoo dot com Assigned:
Status: Not a bug Package: MySQL related
PHP Version: 5.3.1 OS: Linux
Private report: No CVE-ID: None
 [2009-12-13 19:59 UTC] businessitconsulting at yahoo dot com
Description:
------------
Need to display multiple images stored as BLOB data types in a MySQL table. Using a while loop, other fields in the same table with text data type, displays in a browser showing all rows when the BLOB field is not included.

The BLOB data (the images), often are displayed as binary data but needs to show as actual images.

Apparently there is an issue with PHP with displaying the binary data stored in a variable directly as an image when echoing or printing the variable with BLOB data using echo $TheBlobData; or print $TheBlobData;.

In some instances, the query executes, retrieves all rows but only displays an image, instead of all the images per row.

Storing the images in directories has security issues, other risk and the BLOB data needs to be stored and pulled directly from the database.


--------------------
Field Name, DataType
---------------------
ID, int
Picture, BLOB
Type, VARCHAR

For example this prints the ID of each row:
while ($rows = mysql_fetch_row($result))
{
echo $rows->ID;
}
and this prints the image Type stored in a field of each row

while ($rows = mysql_fetch_row($result))
{
echo $rows->Type;
}

but this prints each row of the images as binary data but needs to print actual images:

while ($rows = mysql_fetch_row($result))
{
echo $rows->Picture;
}

When inserting the header() function to describe the image data type, it only prints an image using the same while loop, in some cases it simply shows a blank page and echos the address of the page:

while ($rows = mysql_fetch_row($result))
{
header ();
echo $rows->Picture;
}

This requires printing the multiple BLOB data directly as images to a page for each row in a table and not just an image on the page. For users of Postgres SQL, is this also an issue and are they open source databases where BLOB data types can be displayed directly as images by echoing or printing the BLOB data variable?


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-12-13 20:07 UTC] jani@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Dec 26 12:01:30 2024 UTC