There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
 
Tag Cloud
access audio avg avg 8 bios blue screen boot browser bsod computer cpu crash css dell desktop driver drivers dvd email error excel explorer firefox firefox 3 freeze gimp graphics hard drive hardware hijackthis hjt install internet internet explorer itunes keyboard laptop macro malware missing monitor network networking outlook outlook 2003 outlook 2007 outlook express password popups problem problems router seo server slow sound sp3 spyware trojan usb video virtumonde virus vista vundo windows windows vista windows xp winxp wireless
Web Design & Development
Search
Search in:
 
Advanced Search
Tech Support Guy Forums > Internet & Networking > Web Design & Development >
mysql images


HELLO AND WELCOME! Before you can post your question, you'll have to register -- it's completely free! Click here to join today! We highly recommend that you print a copy of our Guide for New Members. Enjoy!

 
Thread Tools
woody382's Avatar
Junior Member with 28 posts.
 
Join Date: Oct 2007
27-May-2008, 03:39 AM #1
mysql images
Hi,

I have created a mysql database which stores the information sent from a form i designed. Contained in the database are images, which are stored as a blob, which i think is the correct way to store the information.

the problem i am having is that I don't know how to view or retrieve the images. I can't click on the blob or anything.

Please advise what i need to do to retrieve the image and view it.

cheers
Big-K's Avatar
Distinguished Member with 6,883 posts.
 
Join Date: Nov 2003
Location: Kansas
Experience: Advanced
27-May-2008, 09:52 AM #2
Assuming you have php available to you, you need to do something along the lines of this:

fetch.php
//get the sql data, lets call the data for the image $image
imagejpeg($image); //this is assuming the data is a jpeg image

then when you want to output the image, you would have an image tag with a src of 'fetch.php', which can have as many get values as you want. The problem with storing data as blob is that you can't output it directly to the browser, you have to output it in a script then output the script in the img tag.

Another way that only works in firefox, safari, and opera, is to put <img src="data:image/jpeg;base64,****" />, replacing jpeg with the image format and **** with the string you put in the blob field, ala this
http://www.hedgerwow.com/360/dhtml/b...image/demp.php
woody382's Avatar
Junior Member with 28 posts.
 
Join Date: Oct 2007
27-May-2008, 05:32 PM #3
is there another way of storing the information in mysql instead of a blob, which will make it easier to access the images.

cheers
tomdkat's Avatar
Computer Specs
Distinguished Member with 3,418 posts.
 
Join Date: May 2006
Location: S.F. Bay Area, CA
Experience: Intermediate
27-May-2008, 08:07 PM #4
Here is a thread that might be of help.

Peace...
Mudley's Avatar
Computer Specs
Member with 99 posts.
 
Join Date: Apr 2008
Experience: Advanced
28-May-2008, 01:40 AM #5
i'm not a fan of images stored in mysql

store it elsewhere and keep the path or image name in the database
woody382's Avatar
Junior Member with 28 posts.
 
Join Date: Oct 2007
28-May-2008, 06:56 PM #6
this is the code which stores the downloaded images in mysql database. How would i change the code so that the pics shows the path to my upload folder on my server.


@$pfw_strQuery = "INSERT INTO `picfile`(`,`pic 1`,`pic 2`,`pic 3`,`pic 4`,`pic 5`,`pic 6`,`pic 7`)VALUES (\"$pic_1_Name\",\"$pic_2_Name\",\"$pic_3_Name\",\"$pic_4_Name\",\"$pic_5_N ame\",\"$pic_6_Name\",\"$pic_7_Name\")" ;
@$pfw_host = "server name";
@$pfw_user = "user";
@$pfw_pw = "password";
@$pfw_db = "database";
$pfw_link = mysql_connect($pfw_host, $pfw_user, $pfw_pw);
if (!$pfw_link) {
die('Could not connect: ' . mysql_error());
}
$pfw_db_selected = mysql_select_db($pfw_db, $pfw_link);
if (!$pfw_db_selected) {
die ('Can not use $pfw_db : ' . mysql_error());
}
Reply

Tags
mysql, php


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

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
Trackbacks are On
Pingbacks are Off
Refbacks are Off

You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 01:11 AM.
Copyright © 1996 - 2008 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Powered by Cermak Technologies, Inc.