Hello,

I have a mySQL database administered through MyphpAdmin. The database is connected to a PhP page built in Macromedia Dreamweaver. I can view the data in the database through my created Dreameaver Dynamic page. So far so good.

I now want to add some pictures to this database. I want to add another column to each field and place a small jpeg or gif file in there.

Through the MyPHPadmin tools, I simply added another column called image and set it to type Mediumblob., attributes then set to BINARY.

I was then able to browse to a file, and select it. Viewing my table, it seemed as though the file was in there, as the file size was displayed (however that was the only indicator that the database was populated with the image).

Then I tried to add this dynamic image to my created web page but when I tried to preview it in my browser, instead of the image I got lines and lines of symbols (more than a page - not readable)

What my question is, is whether or not the images have been correctly stored into the database or not. If not, this will be why they don't seem to be displaying properly. I've spent the day trying to solve this one. and my searches have usually given me some PHP coding tips or a solution that seems too complicated.
I don't really know, but I would have thought that this could be easily done with MyPHPAdmin. The images are stored locally, and only I will add them to the database manually. I imagine that if I wanted to set it up so users can upload photos to my database some PHP coding may be required, but for my purpose, surely it can be done in PHPMyAdmin?

Please, if anyone has any opinions or advice on these, I would be very grateful to hear it. Even if images can't be added through MyPhpadmin and I have to write some php manually, at least I will know what I must do.

Thanks for reading this.

Cheers,
Adam

    i recommend you not to store the image on your Database
    but you can make a folder specially to store the image and
    use database to store it location and name

    then you can make php script to retrieve the image name and location to display it at your browser

      Thanks a lot Chyan.

      No need to answer this one if you are busy but should I store this folder in my remote server?

      I have absolutely no programming experience at all (I was hoping I could avoid programming altogether by using Php My Admin) - so do you know any good sites or tutorials that might help me out with that script you mentioned?

      Thanks again๐Ÿ˜ƒ

        Then I tried to add this dynamic image to my created web page but when I tried to preview it in my browser, instead of the image I got lines and lines of symbols (more than a page - not readable)

        I'm not sure what you actually did, but I'll start at the beginning.

        Basic HTML: You can not put image data inline in a text file. Instead, you construct a reference
        <img src="someurl">

        The usual trick is to store the image in the filesystem and the image location in the database. Use the location to construct an appropriate HTML img tag. And then just let the Web server do its usual thing with the image.

        If you store image data in a BLOB in a database, you will have to write a separate program to retrieve it and send it as the proper media type.

        Presumably your base PHP script knows the ID of the image that needs to be output, so you can construct a tag that passes the ID value in this form:

        <img src="img.php?id=<?php echo $id; ?>">

        Then you write a separate "img.php" script that looks up the data based on the ID that is passed as a GET argument, then outputs it like so:

        header('Content-type: image/jpeg');
        echo $myblobbyimagestuff;

          Write a Reply...