Current location: Hot Scripts Forums » Other Discussions » Database » storing images in database


storing images in database

Reply
  #1 (permalink)  
Old 08-20-11, 05:10 AM
ravi951 ravi951 is offline
New Member
 
Join Date: Aug 2011
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
storing images in database

hi all,
i want to store an image in MYSQL database.please tell me whether the below sql syntax i have written is correct or not.
Code:
CREATE TABLE IF NOT EXISTS `products`(
  `serial` int(11) NOT NULL auto_increment,
  `name` varchar(20) collate latin1_general_ci NOT NULL,
  `description` varchar(255) collate latin1_general_ci NOT NULL,
  `price` float NOT NULL,
  `picture` varchar(80) collate latin1_general_ci NOT NULL,
  PRIMARY KEY(`serial`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci AUTO_INCREMENT=7;
and i have inserted the values for the above table also.
below is the one.....
Code:
INSERT INTO `products` (`serial`, `name`, `description`, `price`, `picture`) VALUES
(1, 'View Sonic LCD', '19" View Sonic Black LCD, with 10 months warranty', 250, 'images/lcd.jpg'),
(2, 'IBM CDROM Drive', 'IBM CDROM Drive', 80, 'images/cdrom-drive.jpg'),
(3, 'Laptop Charger', 'Dell Laptop Charger with 6 months warranty', 50, 'images/charger.jpg'),
(4, 'Seagate Hard Drive', '80 GB Seagate Hard Drive in 10 months warranty', 40, 'images/hard-drive.jpg'),
(5, 'Atech Mouse', 'Black colored laser mouse. No warranty', 5, 'images/mouse.jpg'),
(6, 'Nokia 5800', 'Nokia 5800 XpressMusic is a mobile device with 3.2" widescreen display brings photos, video clips and web content to life', 299, 'images/mobile.jpg');
the "picture" field stores pictures in database.i have given there VARCHAR(80)
i know for storing pictures we should give BLOB data type.
but tell me whether the above syntax i have written will work or not.
if not what would be the syntax...
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Upload images via form and insert data into MySQL database mike_jandreau PHP 7 04-06-09 06:05 PM
Images in database. Vincent T Script Requests 5 06-02-08 07:38 AM
Need help to store images in mysql database sjems PHP 2 04-12-05 05:36 AM
display images in a datagrid or table from mysql database. bin ASP 1 01-03-05 06:34 PM
Uploading multiple images and save to database peterpeter ASP 0 09-07-04 01:00 AM


All times are GMT -5. The time now is 05:21 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.