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 **假设数据库操作成功。总是假设失败,检查失败,并将成功视为令人惊喜的事情。 –