Jump to content

Issues Viewing Images Stored in Database


bolivartech

Recommended Posts

I am working on a database assignment for a class and I've run into a snag that I just can't seem to figure out. When I try to display images saved in my database they come out garbled, some more viewable than others. The site is http://198.209.19.97/~lkemp/photodb/index.php

There is a second issue, it seems I cannot upload more than 5 images into the database. I don't know if that is a table issue or my php code.

 

I am using

mysql  Ver 14.12 Distrib 5.0.38, for pc-linux-gnu (x86_64) using readline 5.2

5.0.38-Ubuntu_0ubuntu1.4-log Ubuntu 7.04 distribution

 

 

Here are some table descriptions and sample queries and I've attached the source files.

I will not claim that they are all original, quite a bit are compilations from bits found online. This is my first endeavor into php so I looked for samples to get me started.

 
mysql> desc Photo;
+------------------+-------------+------+-----+---------+----------------+
| Field            | Type        | Null | Key | Default | Extra          |
+------------------+-------------+------+-----+---------+----------------+
| PhotoID          | int(11)     | NO   | PRI | NULL    | auto_increment |
| PhotoData        | longblob    | NO   |     |         |                |
| PhotoPopularity  | int(11)     | NO   |     | 0       |                |
| PhotoSize        | int(11)     | NO   |     |         |                |
| PhotoDate        | date        | NO   |     |         |                |
| PhotoDescription | varchar(45) | YES  |     | NULL    |                |
| PhotoName        | varchar(45) | NO   |     |         |                |
| CommentStatus    | tinyint(1)  | NO   |     | 1       |                |
| ViewableStatus   | tinyint(1)  | NO   |     | 1       |                |
| UserName         | varchar(48) | NO   | MUL |         |                |
| CategoryName     | varchar(45) | YES  |     | NULL    |                |
| PhotoType        | varchar(45) | YES  |     | NULL    |                |
+------------------+-------------+------+-----+---------+----------------+
12 rows in set (0.00 sec)

mysql> Select PhotoID, PhotoName, UserName, PhotoType From Photo;
+---------+-----------------------+----------+------------+
| PhotoID | PhotoName             | UserName | PhotoType  |
+---------+-----------------------+----------+------------+
|       1 | windows-logo.jpg      | adavis   | image/jpeg |
|       2 | Truman.jpg            | lkemp    | image/jpeg |
|       3 | Ship.jpg              | lkemp    | image/jpeg |
|       4 | app_full_proxy[3].jpg | lkemp    | image/jpeg |
|       5 | Truman.jpg            | lkemp    | image/jpeg |
+---------+-----------------------+----------+------------+
5 rows in set (0.00 sec)

mysql> Select * From Users;
+----------+----------------------------------+
| UserName | Password                         |
+----------+----------------------------------+
| adavis   | 81dc9bdb52d04dc20036dbd8313ed055 |
| blu      | 81dc9bdb52d04dc20036dbd8313ed055 |
| dkemp    | 12689b7929e72f7cae8bca4d28d6f46a |
| lkemp    | f78f2477e949bee2d12a2c540fb6084f |
| user     | 81dc9bdb52d04dc20036dbd8313ed055 |
+----------+----------------------------------+
5 rows in set (0.00 sec)

mysql> Select * From Users;
+----------+----------------------------------+
| UserName | Password                         |
+----------+----------------------------------+
| adavis   | 81dc9bdb52d04dc20036dbd8313ed055 |
| blu      | 81dc9bdb52d04dc20036dbd8313ed055 |
| dkemp    | 12689b7929e72f7cae8bca4d28d6f46a |
| lkemp    | f78f2477e949bee2d12a2c540fb6084f |
| user     | 81dc9bdb52d04dc20036dbd8313ed055 |
| user2    | 81dc9bdb52d04dc20036dbd8313ed055 |
+----------+----------------------------------+
6 rows in set (0.00 sec)

 

 

 

[attachment deleted by admin]

Link to comment
Share on other sites

I think uploading images in your database is a really bad idea. Every time a query is executed and requests an image, your database load is huge. It will effect the performance of your database very badly. Databases are also limited in size, there might be the problem. I think you can better save the images on your webhosting and then put the filename in the database.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.