8 Replies - 1062 Views - Last Post: 25 January 2008 - 11:36 AM

#1 kia_hm  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 23-January 08

Problems storing images in database

Post icon  Posted 23 January 2008 - 05:02 PM

Dear Guys,
I'm very new in MySql,
I selected varchar for upload a picture, but when I set a query It doesn't show the picture and some times show me the path of picture not the picture exactly.

Thank you very much to help me.
Is This A Good Question/Topic? 0
  • +

Replies To: Problems storing images in database

#2 kia_hm  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 23-January 08

Re: Problems storing images in database

Posted 23 January 2008 - 06:43 PM

Dear guys,

I'm very new in MySql,
I selected varchar for upload a picture, but when I set a query It doesn't show the picture and some times show me the path of picture not the picture exactly.

Thank you very much to help me.
Was This Post Helpful? 0
  • +
  • -

#3 Nykc  Icon User is offline

  • Gentleman of Leisure
  • member icon

Reputation: 726
  • View blog
  • Posts: 8,638
  • Joined: 14-September 07

Re: Problems storing images in database

Posted 23 January 2008 - 06:58 PM

This is like the 4th time you posted this please be patient someone will get around to helping you. but to answer your question.

Try this:

#
# Table structure for table 'tblimage'
#

CREATE TABLE `tblimage` (
  `imgid` int(3) unsigned NOT NULL auto_increment,
  `imgtype` varchar(16) NOT NULL default '',
  `imgdata` mediumblob,
  PRIMARY KEY  (`imgid`)
) TYPE=MyISAM;


This post has been edited by nykc: 23 January 2008 - 06:59 PM

Was This Post Helpful? 0
  • +
  • -

#4 kia_hm  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 23-January 08

Re: Problems storing images in database

Posted 23 January 2008 - 07:01 PM

View Postnykc, on 23 Jan, 2008 - 06:58 PM, said:

This is like the 4th time you posted this, once is enough be patient. but to answer your question.

Try this:

#
# Table structure for table 'tblimage'
#

CREATE TABLE `tblimage` (
  `imgid` int(3) unsigned NOT NULL auto_increment,
  `imgtype` varchar(16) NOT NULL default '',
  `imgdata` mediumblob,
  PRIMARY KEY  (`imgid`)
) TYPE=MyISAM;



Thank you
sorry for send 3 times today is my first day and I am not familiar with this ways,
By the way I want to do it in php my admin not in code area, actually I've started to learn my sql 6 adys ago !!!!!! :wub:
Was This Post Helpful? 0
  • +
  • -

#5 Nykc  Icon User is offline

  • Gentleman of Leisure
  • member icon

Reputation: 726
  • View blog
  • Posts: 8,638
  • Joined: 14-September 07

Re: Problems storing images in database

Posted 23 January 2008 - 07:03 PM

Thats even easier - just use Blob or mediumblob instead of varchar.

Hope that helps..

From personal experiences sometimes its better to call a URL from an image hosted on site than to actually insert image in database to restrict the load. Especially if this is going to be a large database.

This post has been edited by nykc: 23 January 2008 - 07:04 PM

Was This Post Helpful? 0
  • +
  • -

#6 kia_hm  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 23-January 08

Re: Problems storing images in database

Posted 23 January 2008 - 07:13 PM

View Postnykc, on 23 Jan, 2008 - 07:03 PM, said:

Thats even easier - just use Blob or mediumblob instead of varchar.

Hope that helps..

From personal experiences sometimes its better to call a URL from an image hosted on site than to actually insert image in database to restrict the load. Especially if this is going to be a large database.


Thank you,
I'll try and let you know.
Was This Post Helpful? 0
  • +
  • -

#7 Nykc  Icon User is offline

  • Gentleman of Leisure
  • member icon

Reputation: 726
  • View blog
  • Posts: 8,638
  • Joined: 14-September 07

Re: Problems storing images in database

Posted 23 January 2008 - 07:14 PM

View Postkia_hm, on 23 Jan, 2008 - 09:13 PM, said:

View Postnykc, on 23 Jan, 2008 - 07:03 PM, said:

Thats even easier - just use Blob or mediumblob instead of varchar.

Hope that helps..

From personal experiences sometimes its better to call a URL from an image hosted on site than to actually insert image in database to restrict the load. Especially if this is going to be a large database.


Thank you,
I'll try and let you know.


You are welcome.

Good luck :^:
Was This Post Helpful? 0
  • +
  • -

#8 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1639
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: Problems storing images in database

Posted 25 January 2008 - 08:48 AM

I wasn't aware mySQL had a varchar data type, I thought that was specific to Microsoft SQL Server, besides that, if you're storing images as varchar you're not saving anything, at best you're just saving the path to the image (as an image cannot be converted to varchar).

Besides, its very inefficient to store the actual image in the database, store the image on your server and just the path and relavent information about the image in the database. Storing the actual image means there has to be a server call for each image that is to load on every page, not a good use of system resources if you ask me :)
Was This Post Helpful? 0
  • +
  • -

#9 Nykc  Icon User is offline

  • Gentleman of Leisure
  • member icon

Reputation: 726
  • View blog
  • Posts: 8,638
  • Joined: 14-September 07

Re: Problems storing images in database

Posted 25 January 2008 - 11:36 AM

View PostPsychoCoder, on 25 Jan, 2008 - 10:48 AM, said:

I wasn't aware mySQL had a varchar data type, I thought that was specific to Microsoft SQL Server, besides that, if you're storing images as varchar you're not saving anything, at best you're just saving the path to the image (as an image cannot be converted to varchar).



No they have Varchar.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1