Jump to content

Archived

This topic is now archived and is closed to further replies.

hostglory

Display Images from Blob

Recommended Posts

I'm in a major fix right now. I need to display multiple (20+) images from a Blob field in MySQL on a single web page using PHP. The problem arises when I get a 403 forbidden error, which can only mean one thing, too many database connections at one time. I have tried closing the MySQL connection each time I need to display each image, but I'm still getting this error! If anyone knows how to display multiple images from a Blob field on a single web page with PHP, without getting this error, I could really use your help!

Share this post


Link to post
Share on other sites

I don't understand exactly what you mean... how are you storing 20 images in a single BLOB field (or did I miss the piont)? I'm not sure why you think 403 means too many connections, either. Also, how would retrieving 20+ images require multiple DB connections? Or each each image calling it's own PHP script? Please clarify.

Share this post


Link to post
Share on other sites

[!--quoteo(post=332696:date=Jan 3 2006, 03:35 AM:name=fenway)--][div class=\'quotetop\']QUOTE(fenway @ Jan 3 2006, 03:35 AM) 332696[/snapback][/div][div class=\'quotemain\'][!--quotec--]

I don't understand exactly what you mean... how are you storing 20 images in a single BLOB field (or did I miss the piont)? I'm not sure why you think 403 means too many connections, either. Also, how would retrieving 20+ images require multiple DB connections? Or each each image calling it's own PHP script? Please clarify.

 

 

No, let's say I have 20 images, then there would be 20 different rows, one row for each image. I'm calling the images using this method: <img src="getpicture.php?id=1234">

 

Then, in the getpicture.php script, I connect to the database, grab the blob data for that single image, then change the header type and then print out the image. Hopefully this clarify's what I'm trying to do.

Share this post


Link to post
Share on other sites

That's what I thought, it just wasn't clear from your initial post. It seems strange that your DB wouldn't allow 20 simultaneous connections, but it's possible.

Share this post


Link to post
Share on other sites

[!--quoteo(post=332802:date=Jan 3 2006, 12:25 PM:name=fenway)--][div class=\'quotetop\']QUOTE(fenway @ Jan 3 2006, 12:25 PM) 332802[/snapback][/div][div class=\'quotemain\'][!--quotec--]

That's what I thought, it just wasn't clear from your initial post. It seems strange that your DB wouldn't allow 20 simultaneous connections, but it's possible.

 

 

I looked at the MySQL configurations, and it is set to allow 20 max user connections. But, I'm just wondering if there could be anything else causing the 403 error. And, is there a different way to accomplish this without having to make so many database connections?

Share this post


Link to post
Share on other sites

Twenty isn't that many to begin with, but no, if you're going to make 20 images on a page, each retreived via script, then you don't have much of a choice without a whole bunch of undesired hacks. To be honest, there's nothing wrong with 20 connections, as long as each of them isn't doing that much work. In your case, if it's just getting and image and disconnecting, it shouldn't be an issue. BTW, I don't see how this is causing 403 errors; those are web server errors, usually related to permissions, and shouldn't have anything to do with PHP/MySQL-related issues -- the worst you should get would be a timeout.

Share this post


Link to post
Share on other sites

When I get the 403 error, it's usually after I've tried refreshing the page again. The first time the page is displayed it will only produce a 1/4 of the images. I try to refresh, and then it gives me the 403 error. So it's hard to understand what's causing it to produce that error?

Share this post


Link to post
Share on other sites

Could it be possible that I'm maxing out my Apache connections everytime I try to display all these images?

Share this post


Link to post
Share on other sites

That seems highly unlikely, because it would mean that you couldn't have 20 images on a page either!

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.