473,397 Members | 1,972 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

how to get a blob image out of a record?

Iam posting this after trying many tutorials in the NG and failing to
retrieve the blob out of a record. So please bear with me before
before you pull the water hose or flame throwers ......

I can upload a Jpeg image file perfectly. Iam using this snippet to do
that..

<!-- addpic.php snippet !-->
....
$file = fopen($_FILES['pict']['tmp_name'], "rb");
$pic = fread($file, 5000000);
// mysql_query(INSERT .... code goes here

MySQL Admin shows that the picture I have uploaded 430KB as 428KB, not
sure this matters. Now I want to get the image displayed inside my
html page

<!-- html code goes here ---->
<img src="getimg.php?i=8" height=244>

<!-- here is the code snippet for getimg.php to extract the blob
file -->
($row = mysql_fetch_array($result))
$data = $_GET[$row['pic']];
header("Content-type: image/jpeg");
include $data;
// echo $data;
Iam only getting a broken image nothing else. What am I doing wrong?

Appreciate anyone help.

Sam
Jul 17 '05 #1
1 5625
On 19 Mar 2004 11:14:58 -0800, sa**@freeddns.org (sams) wrote:
Iam posting this after trying many tutorials in the NG and failing to
retrieve the blob out of a record. So please bear with me before
before you pull the water hose or flame throwers ......

I can upload a Jpeg image file perfectly. Iam using this snippet to do
that..

<!-- addpic.php snippet !-->
....
$file = fopen($_FILES['pict']['tmp_name'], "rb");
$pic = fread($file, 5000000);
// mysql_query(INSERT .... code goes here
You've snipped the most likely place for a mistake here. How exactly did you
pass the data into the statement? You have to careful since it's binary data.
Did you apply mysql_escape_string()?
MySQL Admin shows that the picture I have uploaded 430KB as 428KB, not
sure this matters.
This may well be due to mangling resulting from not escaping the data
properly.
Now I want to get the image displayed inside my
html page

<!-- html code goes here ---->
<img src="getimg.php?i=8" height=244>

<!-- here is the code snippet for getimg.php to extract the blob
file -->
($row = mysql_fetch_array($result))
$data = $_GET[$row['pic']];
What's $_GET doing here?
header("Content-type: image/jpeg");
include $data;
include?
// echo $data;
That's better.
Iam only getting a broken image nothing else. What am I doing wrong?


--
Andy Hassall <an**@andyh.co.uk> / Space: disk usage analysis tool
<http://www.andyh.co.uk> / <http://www.andyhsoftware.co.uk/space>
Jul 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: John | last post by:
I have over 5000 thumbnail pictures of size 5kb each. I would like to able to load all 5000 pictures and view 50 per page using mysql_data_seek(). I would like to know what are the advantages and...
3
by: NotGiven | last post by:
I am researching the best place to put pictures. I have heard form both sides and I'd like to know why one is better than the other. Many thanks!
0
by: ichor | last post by:
hi i have a blob in my sql server database, that i would like to display on my web page.. i have 2 problems with this. 1). i am able to display it but i cant add any text in the page. 2) also i...
6
by: Pierre-Benoit | last post by:
Hi there, I've a strange problem with ado.net and an Access db. I need to create a little C# app that take the content of "ole object" field and then save it into a file. The problem is that...
11
by: CSN | last post by:
Is it possible to iterate over an array in plpgsql? Something like: function insert_stuff (rel_ids int) .... foreach rel_ids as id insert into table (rel_id, val) values (id, 5);
10
by: Peter Stojkovic | last post by:
I want store an integer-array of 1000 Values in a blob in a SQL-database. I will do this every 10 Seconds. How can I do this ???? What datatypes a have to use ??? Thanks
4
by: Nau | last post by:
How can I display BLOB(Oracle) data in asp page
55
ADezii
by: ADezii | last post by:
Of all the questions asked here at TheScripts, the one which appears with the most frequency relates to the storing of Graphic Images within Access. There are basically three techniques available to...
5
by: simonyong | last post by:
I'm newbie to .net and currently learning to use BLOB to insert image into database What i'm facing is i dont know what is going wrong to make me continue getting this error: An unhandled...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.