I'm trying to populate a database with mp3 audio, I tried using phpMyadmin to upload into a BLOB but it doesn;t seem to work...am I missing something here ??
[RESOLVED] MP3 Audio in mySql database
Not 100% sure you can actually store digital music in the database. How are you reading the mp3? If I were to do this, I'd expect to read it using [man]file_get_contents/man and then store whatever comes back in the BLOB field of mySQL; however, you'd have to (1) know that the item you're getting is really an mp3, and (2) send the correct headers for it once you've retrieved it from the database.
I have a database full of song names, and when a user does a search (which i already have fully working) I want to display a link to an excerpt of the song file.
Is there any other way to do it other than upload small mp3s into the database and return them along with the search results.
Can i put a link into a field ???? Not sure how to proceed ....
Thanks for your help......
You can store anything you want in a text field A URL, some html text, numbers, whatever. So if you store the actual MP3 on your server, and store the path (or link) to it in your database, then you'll be right as rain.
so yes I can store the url, (in this case http://localhost:8888/studio/audio/I_Hear_You_Calling.mp3)
But when I query it it just returns the string above, when what I actually want is a link so that I can play that file.
How do I do that....(sorry newbie)
Thanks for your help so far
You'd have to create the link yourself.... add the <a> tags and such.
Yes i finally got the whole thing to work...
This is the code I used:
$query = "SELECT song_name, url, song_key, artist_name, image
FROM songs.title, songs.artist
WHERE FK_artist = artist_id
AND artist_name LIKE \"%$trimmed%\"
ORDER BY song_name
LIMIT 0 , 20";
$result = mysqli_query($cxn,$query)
or die ("Couldn't execute query.");
/ Display results in a table /
echo "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\">";
echo "<tr bgcolor=\"#A42008\"><td><span class=\"style1\">Artist</span></td><td><span class=\"style1\">Track</span></td><td><span class=\"style1\">Preview</span></td><td><span class=\"style1\">Key</span></td></tr>";
while($row = mysqli_fetch_assoc($result))
{
extract($row);
echo "<tr bgcolor=\"#FED9AF\">\n
<td width=\"30%\">$artist_name</td>\n
<td width=\"50%\">$song_name</td>\n
<td width=\"12%\" align=\"center\"><a href=\"../studio/audio/$url\"><img src = '../images/$image'></a></td>\n
<td width=\"8%\">$song_key</td>\n
</tr>\n";
}
echo "</table>\n";
thanks for your help...
Don't forget to mark this thread as resolved if it is.