Library code snippets

Storing / Retrieving pictures from database

Hi folks

I have searched many sites for storing a picture into a database and retrieve the same. But I got some tutorials when I searched the web. Using the tutorials I have a made one for me. It was implemented using Php and MySQL.

The downloadable ZIP file includes the following files.

  1. index.php
    This files links all the files in the project.
  2. store.php
    This does the job of storing the picture into the database.
  3. viewadd.php
    This file shows the entire picture stored in the database.
  4. getpicture.php
    This file actually gets the file from file in the form of picture
  5. mdbc.inc.php
    This is a class file for Mysql feel free to use. I got this over net.

Here is the table description

       Id - > has the picture id
       Description -> has the picture description
       bin_data -> picture data
       filename -> picture file name
       filetype -> picture file type. Like gif or jpeg etc
       link -> you can store the link incase if you want to use this for ad exchange
       showno - > no of time ad show etc
       clickcount -> no of time the ad being clicked etc
   
Query for the table.

CREATE TABLE ads
   (
       id varchar(15),
       description varchar(255),
       bin_data LONGBLOB,
       filename varchar(50),
       filesize varchar(50),
       filetype varchar(50),
       link varchar(255),
       shownno integer(5),
       clickcount integer(5),
       unique(id)
   );


If you want to see a site where I have implemented please have a look at the site http://www.asksathia.com/

Feel free to change anything in the code. If you developed a better version than this please send me the source code so that I may update myself. It took me much time when commenting the code of ease of understanding.

Please vote for me.

Regards
Imthiaz Rafiq

Comments

  1. 28 Jun 2007 at 15:34

    hi there

    nicely done.

    i have one problem though.

    fatal error: cannot access empty property in ...\mdbc.inc.php on line 68

    if you can help

    thanks

  2. 15 Jan 2007 at 21:36
    Thank you for this example.  I am trying to do the same thin except in OpenOffice.org Base. I do not want to store the image with the datbase only the path and filenme. So, do I add the image path and filename to my table and then call it for my form to view? This is where I get confused.  I want to store the path and filename with a record on the form. Any suggestions?
    Thanks


  3. 03 Apr 2006 at 12:37

    where the zip file is?

  4. 15 Mar 2005 at 05:29

    Sorry I did this stuff for a client. He forgot to renew that domain. Some one else has taken that site and made that one into a spam site.


    I can't help that...

  5. 22 Jan 2005 at 00:25

    I posted this code to my site and I get a id code but no record is put into the database.


    I am not willing to read porn just to see how it is supposed to work.

  6. 07 Dec 2004 at 19:47

    one of the nicest code i've seen and tested (and eventually implemented)
    consice,complete, simple and very understandable

  7. 01 Jan 1999 at 00:00

    This thread is for discussions of Storing / Retrieving pictures from database .

Leave a comment

Sign in or Join us (it's free).

Imthiaz Rafiq Nothing Much

Related podcasts

  • EarthClassMail.com - Moving from LAMP to .NET 3.5

    Scott chats with Matt Davis, architect at EarthClassMail.com, about their move from a LAMP stack (Linux/Apache/mysql/PHP) to .NET 3.5. What's working, what's not, and what kinds of issues are they running into as their architect their solution.

Events coming up

  • Apr 17

    WebTech Conference 2010 - Bulgaria

    Veliko Turnovo, Bulgaria

    6th edition of WebTech conference will be held. A 2 day conference about : - Web Technologies - Blogs and blogging - Web 3.0 - Open Web - Mobile technologies - Internet Business

We'd love to hear what you think! Submit ideas or give us feedback