SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    May 2004
    Location
    Maryland
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Dtoring Images in a database table

    I'm a beginner at SQL design, so can you please help me out in the simplest and on technical form you can. I need to store images in a database table. A table needs to have an image field, description, ref # and price. I tried using both absolute and relative url (as shown below), but when the table outputs, instead of an image, I get the URL string I inserted. (I use MySQL Server). I've heard of BINARY and "putting a raw image" and using an image datatype, but I've no clue how that works, or how to code it. Your immediate help will be greatly appreciated. Here's my code so far:

    $create = "
    CREATE TABLE CClassTable (
    product VARCHAR (130) NOT NULL,
    description VARCHAR (64) DEFAULT NULL,
    reference INT (5) DEFAULT NULL,
    price VARCHAR(15),
    PRIMARY KEY (reference),
    KEY (description)
    )";

    //fill CClass table

    $CClassRow1 = "INSERT INTO CClassTable VALUES ('http://student-iat.ubalt.edu/dynamic/zmrisho/Final%20Project/Final%20Project/images/c-class/cdchanger.jpg','CD Changer','1018','$55.20/EA')";
    (...AND SO ON)

  2. #2
    SitePoint Wizard jonese's Avatar
    Join Date
    Jul 1999
    Location
    Powder Springs GA (Atlanta)
    Posts
    1,238
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you said you were getting the url string when you outputted the table data? how were you orginially outputting this data? within an image tag? or as a text string.

    binary is ok for storage but it actually takes up more room on your server etc than storing the image / file locally and then referancing it in the DB.

  3. #3
    SitePoint Member
    Join Date
    May 2004
    Location
    ahmedabad
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I am unable to store file upload (form field) to blob in mysql for image store ? can you help me ?


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •