can somebody please tell me what's wrong with my code ?! i stored the file path in my database as varchar
and it's 01.mp3 and the file is right next to the php file but it's not working and i'm using Mysql
here's the function file getAudio.php
<?php
include 'conn.php';
// to connect with the database
$id = $_GET['id'];
// validation just to be safe
$sql = "SELECT file FROM filepath 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
echo $row['file'];
//calls the audio file and returns it in the src attribute
?>
and here's where i'm trying to echo it song.php
<?php
include 'conn.php'; ?>
<html>
<head><title></title></head>
<body>
<audio controls>
<source src="<?php echo '/getAudio.php?id=1/';?>" type="audio/mpeg">
</audio>
</body>
</html>
and when i replace the ''
with ""
the audio appears but it doesn't play