send audio file to mysql database table

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
sudhakar_ssr
Forum Newbie
Posts: 1
Joined: Thu Aug 11, 2011 12:14 pm

send audio file to mysql database table

Post by sudhakar_ssr »

Hello every

Am sudhakar learner of php. Am designing a website i want to insert some audio and image files in the database table. and also i want them to display from table. how can we insert such files and retrieve them please help me with the code.

Thank You.
ThatPerson
Forum Commoner
Posts: 50
Joined: Wed Aug 03, 2011 1:57 am

Re: send audio file to mysql database table

Post by ThatPerson »

I am not entirely sure what you mean, but I think to are wondering how you can display images from a MySQL database or insert them. If the images are local you could just have the path (../images/image.jpg) in the database and have:

Code: Select all

$img = mysql_fetch_object(mysql_query("select image from table where something = something else")) -> image;
echo "<div style="background:url($img)"></div>"; #I know, I use divs for images, it is a thing that I just constantly do
To insert the image you could run this mysql

[text]insert into image database values("../images/image.jpg","Hi There");[/text]
xtiano77
Forum Commoner
Posts: 72
Joined: Tue Sep 22, 2009 10:53 am
Location: Texas

Re: send audio file to mysql database table

Post by xtiano77 »

If I are referring to storing files in the database as "BLOB", then check out the link below for a code example on how to do it.

http://www.php-mysql-tutorial.com/wikis ... abase.aspx
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: send audio file to mysql database table

Post by califdon »

As indicated by the other 2 responses, this is quite possible, but it is the general opinion of many (if not most) web developers that it is better NOT to store binary data like audio and video and images in a database. As ThatPerson suggested, it is the customary method to store the path to the file in the database, then use that path to embed the href attribute in an appropriate HTML element, such as <img...> for images.
Post Reply