PHP Troubleshooting Audio & Image will not load on new page

A

Anonymous

Guest
I am new to PHP language and I need some help. The hyperlink loads the image and audio player on new page but I cannot figure out why the audio file will not play.
Here is some background information. The website is bilingual (English & Spanish) which means one side of the website is written in English only and the other side of the website is written in Spanish only. The script is written to show the correct language and play the correct mp3 audio file (English or Spanish) according to the language of the site a person is visiting. The script uses a MYSQL database to accomplish this task for the hyperlink (includes text and a date) which means if a person is on the Spanish side of the website the hyperlink appears in Spanish and same goes for English side of the website. Each week, I load two new mp3 files (English & Spanish) and link them to the Spanish or English text with a date in the database. Not sure why the audio file will not play. there are two php files (wmb & play). wmb.php file works great since the hyperlink references the correct image and audio file but I suspect that the play.php has issues with the mp3 file. The root directory for the play.php file is in "modules/music/" and the mp3 audio files (55-0117_ENG.mp3 & 55-0117_SPN.mp3) are found in the root directory of "dashboard/files/wmb/" while the wmb.php file is located in "modules/home/"
Need help please understanding why the mp3 file does not play.

wmb.php file
<?php
$query = " SELECT * FROM wmb WHERE lang='$lang' ORDER BY id DESC ";
$result = mysql_query($query) or die(mysql_error());
$row = mysql_fetch_array($result);
echo "<a href='modules/music/play.php?song=".$row['link'].'&image='.$‌​row['image']."' target='_blank'>".$lang_wmb7.$row['date']."</a>"; echo '<hr />';
?>

Play.php file
<html> <body> <?php $image = $_GET['wmbvog.jpg']; //ie image of an specific author
$song = $_GET['link']; // ie somesong.mp3
echo '<img src="pictures/wmbvog.jpg" height="475" width="777"><br> <audio controls autoplay> href='dashboard/files/wmb/".$row['link']."' </audio>'; ?> </body> </html>

The hyperlink on the new page reads as follows:
modules/music/play.php?song=55-0117_ENG.mp3&image=

The image loads correctly and it has selected the correct audio file (55-0117_ENG.mp3) but the player is not playing the audio file on the new page.
 
Here's the code for the play.php file

Code:
<html>
<body>

<?php

$image = $_GET[image];
$song = $_GET[link];
?>

<img src="pictures/<?php echo $image; ?>" height="475" width="777"><br>

<audio controls autoplay>
  <source src="dashboard/files/wmb/<?php echo $song; ?>" type="audio/mpeg">
  Your browser does not support the audio tag.
</audio>

</body>
</html>

BTW the new design of this website sucks. Faint text, dark background. Difficult to read.
 
Thank you for your help. I am very grateful. Please forgive my ignorance I do not know php that well. I'm a novice in php language. I made the changes to my play.php as listed above (without making any changes) but now the image does not load and the audio still does not play. I have two questions. How does the new play.php file know which jpg file to select as the image? Where am I supposed to link the wmbnog.jpg image in the play.php file?

In regards to the audio file, if I do a hyperlink like the one below with only audio in a new tab and no image or play.php file

Code:
echo "<a href='dashboard/files/wmb/".$row['link']."' target='_blank'>".$lang_wmb7.$row['date']."</a>";
	
	echo

The correct mp3 audio language file will play on a new tab in a black background screen. The ".$row['link']."' coding selects the correct mp3 language (English – Spanish) audio file and plays it perfectly but why does it not work in the play.php file?
I'm so thankful for your help, patience and your time.
 
Back
Top