1
我插入音頻文件到我的數據庫,我是retreiving他們就好了,然後一些文件只是不會檢索即使我使用相同的代碼這裏的代碼 getAudio .PHP無法從數據庫檢索longblob音頻文件
<?php
include 'conn.php';
// to connect with the database
$id = $_GET['id'];
// validation just to be safe
$sql = "SELECT file FROM letters1 WHERE id=$id";
// choose the column from the table where the id= the id of the audio file
$result = mysql_query("$sql");
//query the audio file
$row = mysql_fetch_assoc($result);
//Returns an associative array
mysql_close($link);
//closes the non-persistent connection to the MySQL
header("Content-type: audio/mpeg");
//audio/wav for wav files mpeg for mp3 files, we used mp3 cuz
//wav didn't work on IE so just to be sure
echo $row['file'];
//calls the audio file and returns it in the src attribute
?>
returnblobfile.php
<?php include 'php/conn.php'
?>
<!DOCTYPE html>
<head><title>new</title></head>
<body>
<audio controls>
<source src="php/getAudio.php?id=14" type="audio/mpeg">
</audio>
</body>
</html>
我使用phpMyAdmin的它停在ID 14,16,19,20,他們是不是空的我一直在編輯它們。 請幫助..在此先感謝
你很容易受到[sql注入攻擊](http://bobby-tables.com)的影響,並且只是假設你的查詢成功了。從來沒有** EVER **假設數據庫操作成功。總是假設失敗,檢查失敗,並將成功視爲令人驚喜的事情。 –