doujue9767 2015-06-19 18:58
浏览 356

如何在mysql数据库表中存储音频文件路径

i am struggling to store mp3 files URL/path in my songs table url field. i am using xampp and mysql with phpmyadmin since i have very little knowledge about sql i have no idea how exactly i should refer my mp3 files path to songs table field! my mp3 files are located in Local drive E and this is the address of one of my mp3 file

E:\Entertainment Lib\Music Library\The Beatles\The Beatles A Hard Day's Night\If I Fell.mp3

but after putting it in database table it doesn't work for me. screenshot of my database table is here-plz check this and finally this is the script that i used to fetch random song from my database table

 <?php

 if(!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest'){ 

include_once "ez_sql_core.php";
include_once "ez_sql_mysql.php";
$db = new ezSQL_mysql('root','','test','localhost'); 

$song = $db->get_row("SELECT * FROM songs ORDER BY RAND() LIMIT 1");

$artist = $song->artist;
$songname = $song->title;
$url = $song->url;
$separator = '|';
echo $url.$separator.$artist.$separator.$songname;
} 

?>
<script type="text/javascript">
$(document).ready(function(){
$("#jquery_jplayer_1").jPlayer({
    ready: function () {
        var data = $.ajax({
          url: "/js/getsong.php",
          async: false
         }).responseText;

        var string = data.split('|');
        $(this).jPlayer("setMedia", {
            mp3: string[0]
        }).jPlayer("play");

        $('#artist').html(string[1]);
        $('#songname').html(string[2]);
    },
    ended: function (event) {  
        var data = $.ajax({
          url: "/js/getsong.php",
          async: false
         }).responseText;

        var string = data.split('|');
        $(this).jPlayer("setMedia", {
            mp3: string[0]
        }).jPlayer("play");

        $('#Miaow').html(string[1]);
        $('#Hidden').html(string[2]);
    },
    swfPath: "js/jPlayer",
    supplied: "mp3"
  });
});
</script>

i will be very thankful to the person who will helps me to solve this problem.

  • 写回答

1条回答 默认 最新

  • dongmeirang4679 2015-06-19 20:06
    关注

    You need to escape your backslashes

    "E:\\Entertainment Lib\\Music Library\\The Beatles\\The Beatles A Hard Day's Night\\If I Fell.mp3"
    

    the \ is an excape character in mysql strings.

    评论

报告相同问题?

悬赏问题

  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?
  • ¥15 matlab(相关搜索:紧聚焦)
  • ¥15 基于51单片机的厨房煤气泄露检测报警系统设计
  • ¥15 Arduino无法同时连接多个hx711模块,如何解决?
  • ¥50 需求一个up主付费课程
  • ¥20 模型在y分布之外的数据上预测能力不好如何解决