I don't know how to add songs in the database along with their link, content_type, duration, size, etc.
I don't know which query & what datatype will be required to add the songs inside a database table.
Since music file is a .mp3 or .wav data I cannot possibly add it inside the database table without the proper knowledge.
I checked it on the internet but did not found any thing special.
Also what is the maximum size of the song that I can store in the database table?

I only need to know how a song can be added inside the database table?
The datatype for the song required?
The maximum size of the song that can be stored inside the database, since i have song files that are about 7MB-10MB large.

4 Years
Discussion Span
Last Post by pixelsoul

Are you trying to store the music file itself as a blob, or are you storing a path for the file and relevant metadata? Because the former isn't recommended and the latter is trivial as long as you have a way of extracting the metadata.


Is there a requirement to actually store the song within your database? Have you considered storing it to the file system and simply store information about the song and its location in a DB table?


yeah i can also store the link in the DB table
thnx for the idea

But how can i store the link into the database?
Should i use the varchar(MAX) or something other datatype?
How am I gonna retrieve it when I need to show it on the webpage?
The "select" query can be used like select SName, SLink, SComp, SSing, SDuration from Songs??


Yes varchar could be the data type. You simply store the path of where you are saving the file and Retreive that info with a select and use that data to build the link (href) of you it as needed.


Is this the OK way to play the song online after fetching from database

<audio src="the code for retrieving song from DB" />


If you are using the <audio> element, you should note that this is an HTML5 element and that while most browsers support it, IE pre v9 will not.

In addition, you are not using the audio element appropriately. The audio element should have source elements as a child of the audio element. You can even include text in the event that the element is not supported by the browser. Its a good idea to include more than one format since browsers do not all support mp3. For example...

<audio controls>
  <source src="audio1.mp3" type="audio/mpeg">
  <source src="audio1.ogg" type="audio/ogg">
  Your browser does not support this audio format.

For more information and demo about the audio element: HTML5 Audio


oh yeah i forget that the code i written was actually for embed at first & then later changed the embed to audio


Adding to what JorgeM said, you can also include a JS or Flash fall back for the browsers that don't support rather than a message that it isn't supported.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.