Jump to content


Photo

Display Images from Blob


  • Please log in to reply
8 replies to this topic

#1 hostglory

hostglory
  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 03 January 2006 - 06:49 AM

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!
Thanks!
Brandon

[a href="http://www.hostglory.com/" target="_blank"]www.hostglory.com[/a]
[a href="http://www.modmyspace.com/" target="_blank"]www.modmyspace.com[/a]
[a href="http://www.uploadsystem.com/" target="_blank"]www.uploadsystem.com[/a]

#2 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 03 January 2006 - 09:35 AM

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.
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.

#3 hostglory

hostglory
  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 03 January 2006 - 06:08 PM

[!--quoteo(post=332696:date=Jan 3 2006, 03:35 AM:name=fenway)--][div class=\'quotetop\']QUOTE(fenway @ Jan 3 2006, 03:35 AM) View Post[/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.
[/quote]


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.
Thanks!
Brandon

[a href="http://www.hostglory.com/" target="_blank"]www.hostglory.com[/a]
[a href="http://www.modmyspace.com/" target="_blank"]www.modmyspace.com[/a]
[a href="http://www.uploadsystem.com/" target="_blank"]www.uploadsystem.com[/a]

#4 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 03 January 2006 - 06:25 PM

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.
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.

#5 hostglory

hostglory
  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 03 January 2006 - 06:37 PM

[!--quoteo(post=332802:date=Jan 3 2006, 12:25 PM:name=fenway)--][div class=\'quotetop\']QUOTE(fenway @ Jan 3 2006, 12:25 PM) View Post[/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.
[/quote]


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?
Thanks!
Brandon

[a href="http://www.hostglory.com/" target="_blank"]www.hostglory.com[/a]
[a href="http://www.modmyspace.com/" target="_blank"]www.modmyspace.com[/a]
[a href="http://www.uploadsystem.com/" target="_blank"]www.uploadsystem.com[/a]

#6 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 03 January 2006 - 07:14 PM

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.
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.

#7 hostglory

hostglory
  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 03 January 2006 - 07:46 PM

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?
Thanks!
Brandon

[a href="http://www.hostglory.com/" target="_blank"]www.hostglory.com[/a]
[a href="http://www.modmyspace.com/" target="_blank"]www.modmyspace.com[/a]
[a href="http://www.uploadsystem.com/" target="_blank"]www.uploadsystem.com[/a]

#8 hostglory

hostglory
  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 03 January 2006 - 08:23 PM

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

[a href="http://www.hostglory.com/" target="_blank"]www.hostglory.com[/a]
[a href="http://www.modmyspace.com/" target="_blank"]www.modmyspace.com[/a]
[a href="http://www.uploadsystem.com/" target="_blank"]www.uploadsystem.com[/a]

#9 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 03 January 2006 - 09:39 PM

That seems highly unlikely, because it would mean that you couldn't have 20 images on a page either!
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users