Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-25-2007, 01:06 PM   PM User | #1
alex57
Regular Coder

 
Join Date: Sep 2006
Posts: 216
Thanks: 9
Thanked 0 Times in 0 Posts
alex57 has a little shameless behaviour in the past
PHP and Images

Hello,

I am having problems finding a site to instruct me on how to retrieve images from a MySQL database, I wonder if anyone could help me. This is the sql of the table used to store the images.

Code:
CREATE TABLE `images` (
  `PremTeamID` mediumint(15) NOT NULL,
  `ImageID` mediumint(15) NOT NULL auto_increment,
  `ImageName` varchar(15) collate latin1_general_ci NOT NULL,
  `Image` blob NOT NULL,
  PRIMARY KEY  (`ImageID`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci AUTO_INCREMENT=4 ;
I am totally lost on how to retrieve the images. Any example scripts would be really useful. thanks.
alex57 is offline   Reply With Quote
Old 01-25-2007, 06:40 PM   PM User | #2
Fumigator
UE Antagonizer


 
Fumigator's Avatar
 
Join Date: Dec 2005
Location: Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
Posts: 7,687
Thanks: 42
Thanked 637 Times in 625 Posts
Fumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of light
Here's a link that contains a pretty good explanation why storing images in blob type fields is a bad idea:

mysql forum post

But if you still want to, the way to do it is via imagecreatefromstring().
__________________
Fumigator is offline   Reply With Quote
Old 01-25-2007, 07:05 PM   PM User | #3
GJay
Senior Coder

 
Join Date: Sep 2005
Posts: 1,791
Thanks: 5
Thanked 36 Times in 35 Posts
GJay is on a distinguished road
That explanation isn't very good, misses out options that involve DB storage, but not a PHP-based rendering. An example:

page is loading,
code looks up which images are associated with the page,
checks to see if the images exist in the disk-cache,
if they don't it pulls them and puts them there,
the src in the img tags refers to this known cache location.
Avoids all the flaws that article mentions, and has the benefit that you can have the CMS system (where you upload the images) separate from the website, with a shared database.

We have a single CMS system for all our clients that is on a machine of it's own. The database is on a machine of its own. We have a separate 'farm' of load-balanced web-servers handling the sites.
__________________
My thoughts on some things: http://codemeetsmusic.com
And my scrapbook of cool things: http://gjones.tumblr.com
GJay is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 03:46 AM.


Advertisement
Log in to turn off these ads.