473,671 Members | 2,370 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Pictures in mySQL

Hey guys,
I am creating a code out of bits and pieces I found in somebody else's
code, so I am not entirely sure how it behaves.

<IMG SRC="picture.ph p?ID=1029&THUMB =yes">

picture.php:
<?
Header( "Content-type: image/jpg");
$linkID = mysql_connect(" host", "user", "password") ;
mysql_select_db ("database", $linkID);
if(isset($_GET['ID'])){$ID=$_GET['ID'];}else{$ID=0;}
$result=mysql_q uery("SELECT * FROM picture_base WHERE ID=$ID") or
die("Can't perform Query");
$row=mysql_fetc h_object($resul t);
if(isset( $_GET['THUMB']){echo $row->THUMB}else{ech o $row->IMG;}
?>
The script works and displays pictures properly so I am happy with it.
Its small and simple enough, my question is if not every site is
saving their pictures in databases there must be a reason why, yes?
And if I load picture.php?ID= 1029&THUMB=yes as opposed to picture.php?
ID=1029, will the script still load through the full sized image (in
the IMG collum) and will that effect my traffic?

thank you

May 1 '07 #1
9 2450
On Apr 30, 8:39 pm, blessblessbl... @gmail.com wrote:
Hey guys,
I am creating a code out of bits and pieces I found in somebody else's
code, so I am not entirely sure how it behaves.

<IMG SRC="picture.ph p?ID=1029&THUMB =yes">

picture.php:
<?
Header( "Content-type: image/jpg");
$linkID = mysql_connect(" host", "user", "password") ;
mysql_select_db ("database", $linkID);
if(isset($_GET['ID'])){$ID=$_GET['ID'];}else{$ID=0;}
$result=mysql_q uery("SELECT * FROM picture_base WHERE ID=$ID") or
die("Can't perform Query");
$row=mysql_fetc h_object($resul t);
if(isset( $_GET['THUMB']){echo $row->THUMB}else{ech o $row->IMG;}
?>
The script works and displays pictures properly so I am happy with it.
Its small and simple enough, my question is if not every site is
saving their pictures in databases there must be a reason why, yes?
And if I load picture.php?ID= 1029&THUMB=yes as opposed to picture.php?
ID=1029, will the script still load through the full sized image (in
the IMG collum) and will that effect my traffic?

thank you
I save all my images in a folder as it reduces stress on the database
server. However, they are stored outside of public view. Php can then
show the images when requested. As for your second question, it really
depends on your setup. If you designed the script to display the full
view if you didn't request a thumb, then it would, or at least should,
work as stated above.

May 1 '07 #2
And if I load picture.php?ID= 1029&THUMB=yes as opposed to picture.php?
ID=1029, will the script still load through the full sized image (in
the IMG collum) and will that effect my traffic?
yes that appears to be what it does.. if you load a full sized image
then yes it will have a greater affect on your bandwidth and traffic
useage than just a thumbnail.. when someone requests a thumbnail from
you the server shrinks it locally so its not using any traffic other
than displaying the thumbnail.

Flamer.
May 1 '07 #3
thank you you two.
i understand now that it will run the image locally and only display
the thumb.
but what is this stress on database, as of when is it considered
stressful? when loading 20 thumbs at the same time? or when hundreds
of people look at it at the same time?
this is just for a private portfolio of a photographer. so its not
aimed at the masses.
will this picture be stored temporarily on a private persons computer
like with normal images, or will it load new every a person visits the
page another time?
bless

May 1 '07 #4
>but what is this stress on database, as of when is it considered
>stressful? when loading 20 thumbs at the same time? or when hundreds
of people look at it at the same time?
Both..the database will run flat out trying to serv either case...you
will need a reasonably fast pc/db to do either (well)!

The "stress" on the database is due to it's field size. The Images
will need to be stored in a blob field or equivelant and that takes up
a substantial amount of space in the database which may reduce search
times etc. If your database is properly indexed and you dont have
thousands of images in the db then this shouldn't really cause a
problem.

I've used both methods in the past (db & file) and I have to say that
I prefer doing things with the file system...it make for easier
maintenance!

May 1 '07 #5
On May 1, 4:39 am, blessblessbl... @gmail.com wrote:
Hey guys,
I am creating a code out of bits and pieces I found in somebody else's
code, so I am not entirely sure how it behaves.

<IMG SRC="picture.ph p?ID=1029&THUMB =yes">

picture.php:
<?
Header( "Content-type: image/jpg");
$linkID = mysql_connect(" host", "user", "password") ;
mysql_select_db ("database", $linkID);
if(isset($_GET['ID'])){$ID=$_GET['ID'];}else{$ID=0;}
$result=mysql_q uery("SELECT * FROM picture_base WHERE ID=$ID") or
die("Can't perform Query");
$row=mysql_fetc h_object($resul t);
if(isset( $_GET['THUMB']){echo $row->THUMB}else{ech o $row->IMG;}
?>
The script works and displays pictures properly so I am happy with it.
Its small and simple enough, my question is if not every site is
saving their pictures in databases there must be a reason why, yes?
And if I load picture.php?ID= 1029&THUMB=yes as opposed to picture.php?
ID=1029, will the script still load through the full sized image (in
the IMG collum) and will that effect my traffic?

thank you
it might be worth googling for sql injection attacks, and follow good
practice with the code.
$ID=$_GET['ID']
mysql_query("SE LECT * FROM picture_base WHERE ID=$ID") !!
also lookup mysql_real_esca pe_string() if php5

May 1 '07 #6
bl************* @gmail.com wrote:
Hey guys,
I am creating a code out of bits and pieces I found in somebody else's
code, so I am not entirely sure how it behaves.

<IMG SRC="picture.ph p?ID=1029&THUMB =yes">

picture.php:
<?
Header( "Content-type: image/jpg");
$linkID = mysql_connect(" host", "user", "password") ;
mysql_select_db ("database", $linkID);
if(isset($_GET['ID'])){$ID=$_GET['ID'];}else{$ID=0;}
$result=mysql_q uery("SELECT * FROM picture_base WHERE ID=$ID") or
die("Can't perform Query");
$row=mysql_fetc h_object($resul t);
if(isset( $_GET['THUMB']){echo $row->THUMB}else{ech o $row->IMG;}
?>
The script works and displays pictures properly so I am happy with it.
Its small and simple enough, my question is if not every site is
saving their pictures in databases there must be a reason why, yes?
And if I load picture.php?ID= 1029&THUMB=yes as opposed to picture.php?
ID=1029, will the script still load through the full sized image (in
the IMG collum) and will that effect my traffic?

thank you
I've been storing everything from scanned documents to pictures in
databases for over 20 years. It works fine. And the larger the number
of images, the better it outperforms a file system.

For instance - how many file systems do you know can manage 100K files
in a single directory? A RDB can easily handle 10M pictures. There's
no "stress" on the database. But it can be a lot of "stress" on a file
system.

--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attgl obal.net
=============== ===
May 1 '07 #7
On May 1, 5:58 am, blessblessbl... @gmail.com wrote:
thank you you two.
i understand now that it will run the image locally and only display
the thumb.
but what is this stress on database, as of when is it considered
stressful? when loading 20 thumbs at the same time? or when hundreds
of people look at it at the same time?
this is just for a private portfolio of a photographer. so its not
aimed at the masses.
will this picture be stored temporarily on a private persons computer
like with normal images, or will it load new every a person visits the
page another time?
bless
you will be lucky if you can get 100 simultaneous requests! actually
most simple (non-load-blanced) web servers wouldnt handle that many.
the stress would come if each picture was large, not because the
database couldnt handle them - after all a table is a file somewhere
on a filesystem, but because if the database lives on another machine,
you will have to set up a TCP connection, and retrieve the data across
the network, then output to the client.
SQL was designed partly to stop the need for huge chunks of data
travelling across the network to be sorted, instead SQL sorted the
data and only sent what was needed. In the same way, /IF/ you organise
your pictures properly on the local filesystem (N directories each
with a sensible max limit, a non system disk for pure data storage
etc. etc..), set up the web server properly, retrieval will be faster,
perhaps easier to maintain and backup.
however as you scale up you will find your pictures are "non-local"
anyway, so a distributed database is an equivalent option after all!

May 1 '07 #8
On May 2, 12:18 am, Jerry Stuckle <jstuck...@attg lobal.netwrote:
blessblessbl... @gmail.com wrote:
Hey guys,
I am creating a code out of bits and pieces I found in somebody else's
code, so I am not entirely sure how it behaves.
<IMG SRC="picture.ph p?ID=1029&THUMB =yes">
picture.php:
<?
Header( "Content-type: image/jpg");
$linkID = mysql_connect(" host", "user", "password") ;
mysql_select_db ("database", $linkID);
if(isset($_GET['ID'])){$ID=$_GET['ID'];}else{$ID=0;}
$result=mysql_q uery("SELECT * FROM picture_base WHERE ID=$ID") or
die("Can't perform Query");
$row=mysql_fetc h_object($resul t);
if(isset( $_GET['THUMB']){echo $row->THUMB}else{ech o $row->IMG;}
?>
The script works and displays pictures properly so I am happy with it.
Its small and simple enough, my question is if not every site is
saving their pictures in databases there must be a reason why, yes?
And if I load picture.php?ID= 1029&THUMB=yes as opposed to picture.php?
ID=1029, will the script still load through the full sized image (in
the IMG collum) and will that effect my traffic?
thank you

I've been storing everything from scanned documents to pictures in
databases for over 20 years. It works fine. And the larger the number
of images, the better it outperforms a file system.

For instance - how many file systems do you know can manage 100K files
in a single directory? A RDB can easily handle 10M pictures. There's
no "stress" on the database. But it can be a lot of "stress" on a file
system.

You raised an interesting point here I am working on a project
currently with around 10million photos, some folders have 20k+ photos
in each, ranging from a few hundred kbs to 6mb each.. would you
recommend using a database over files? Would MySQL be suitable?

Flamer.

May 4 '07 #9
flamer di******@hotmai l.com wrote:
On May 2, 12:18 am, Jerry Stuckle <jstuck...@attg lobal.netwrote:
>blessblessbl.. .@gmail.com wrote:
>>Hey guys,
I am creating a code out of bits and pieces I found in somebody else's
code, so I am not entirely sure how it behaves.
<IMG SRC="picture.ph p?ID=1029&THUMB =yes">
picture.php :
<?
Header( "Content-type: image/jpg");
$linkID = mysql_connect(" host", "user", "password") ;
mysql_select_db ("database", $linkID);
if(isset($_GET['ID'])){$ID=$_GET['ID'];}else{$ID=0;}
$result=mysql_q uery("SELECT * FROM picture_base WHERE ID=$ID") or
die("Can't perform Query");
$row=mysql_fetc h_object($resul t);
if(isset( $_GET['THUMB']){echo $row->THUMB}else{ech o $row->IMG;}
?>
The script works and displays pictures properly so I am happy with it.
Its small and simple enough, my question is if not every site is
saving their pictures in databases there must be a reason why, yes?
And if I load picture.php?ID= 1029&THUMB=yes as opposed to picture.php?
ID=1029, will the script still load through the full sized image (in
the IMG collum) and will that effect my traffic?
thank you
I've been storing everything from scanned documents to pictures in
databases for over 20 years. It works fine. And the larger the number
of images, the better it outperforms a file system.

For instance - how many file systems do you know can manage 100K files
in a single directory? A RDB can easily handle 10M pictures. There's
no "stress" on the database. But it can be a lot of "stress" on a file
system.


You raised an interesting point here I am working on a project
currently with around 10million photos, some folders have 20k+ photos
in each, ranging from a few hundred kbs to 6mb each.. would you
recommend using a database over files? Would MySQL be suitable?

Flamer.
Yep, databases work well for this kind of thing, if they're structured
correctly. And MySQL will do a good job for you.

But you really should be asking this in comp.databases. mysql.

--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attgl obal.net
=============== ===
May 4 '07 #10

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

Similar topics

2
2654
by: NotGiven | last post by:
Please help me understand the big picture of allowing users to upload pictures and keep them separate and tied to their record in the database. I want the whole thing automated and I'm just trying to get my arms around what all is entailed. Each user will upload about 20 - 100 pictures and each will be related to a different database record. I see the process in general as this:
3
3136
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
2022
by: JakeC | last post by:
Hey all, I'm currently redesigning a website that a friend and I started about a year ago. It is a daily surf report so when choosing the best script/language to use for the new design, I found that a mixture of PHP and MySQL would be a good idea. I have currently set up OmniHTTPd and installed MySQL and PHP onto my homeserver. I want the site to be set up as follows: 1- I add the report, date and pictures (and amount of pictures...
3
2010
by: Jim S. | last post by:
Hi guys, i have lots of data for products (with different categories) and pictures that i would need it entered into a database on the website. How would i go about doing so? i was thinking about an excel sheet with each category as a sheet but i have no idea what to do about the pictures that will go with each product, (since i would not want the pictures in the mysql database.) any ideas?
13
2189
by: gooze | last post by:
Hello I am working on an applicaion that shows several pictures on a webpage. These pictures are saved in a MySQL DB as BLOB. I noticed, that the web server suffers in its performance by printing the pictures. Let's say there are 20 pictures to show, there also are 20 queries to do. This is the way I am doing it up to now: index.php <?php
9
3664
by: C.Joseph Drayton | last post by:
Hi All, I have a web site I am developing, and have a question. I would like members to be able to upload pictures. Do you think they should be saved as individual files or should they be put in an MySQL database? Which would you recommend, and do you have any sample code for accomplishing this? Ciao . . . C.Joseph
3
4732
by: Michael martin | last post by:
I'm trying to create a picture database for a site that I'm working on and I would like to do the following: - (main goal) Have a php script load an entire directory of photos into my mysql database in one swoop. - Display thumbnails on a general viewing page. - allow for viewing individual pictures by clicking on the thumbnails. <?php error_reporting(E_ALL); $id = $_REQUEST;
8
1559
by: cbmeeks | last post by:
I am writing my own family photo sharing site that I hope to take public (like so many others). Anyway, currently, when the user uploads a picture, I store the picture outside my htdocs folder and record the image details in a MySQB db. When you browse the picture, I read the record and build the image by sending an image/jpeg header. Seems to work but I am a little disappointed with performance. Granted I am running on a really old...
1
3799
oranoos3000
by: oranoos3000 | last post by:
hi would you please help me i have a online shopping center that i show pictures of the my product in home page. in the InterExplorer pictures is shown correctly but in Firefox browser is shown properties alt in img tag istead of picture . place of the pictures is saved in the database(my database is with mysql) and in home page i fetch properties of the product and address of place that pictures is located output of the code in the...
0
8472
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8390
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8909
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8819
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8667
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7428
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6222
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5690
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
2
2048
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.