I wanted to ask you what is wrong with this code that does not return musixmatch song lyrics.
Unfortunately I do not know about programming, I changed the values (url, api_key and the tags to return). The data q_artist and q_track take them from the database installed on my server ($ artist and $ song). The link you should send is (for example): link ?
I appreciate any guidance you can give me.
<?php
// Connection to the database.
$con = mysqli_connect($database_ip, $database_user, $database_pass,
$database_name, $database_port);
//On error.
if (mysqli_connect_errno()){ echo "No connection to the database."; }
?>
<?php
$con_his= "SELECT *, history.duration-TIMESTAMPDIFF(SECOND,
history.date_played, NOW())
AS remaining
FROM history, songs
WHERE songs.title = history.title AND songs.artist = history.artist
AND history.song_type = 0
ORDER BY history.date_played DESC
LIMIT 1";
$result = mysqli_query($con, $con_his );
while($row = mysqli_fetch_assoc($result)) {
$artist= $row['artist'];
$song= $row['title'];
}
?>
<center><h3><?php echo $song ?></h3></center>
<script>
$.getJSON("https://api.musixmatch.com/ws/1.1/matcher.lyrics.get?
format=jsonp&q_track=$song&q_artist=$artist&apikey=
xxxx&callback=?"
, function(data) {
var lyrics = data.message.body.lyrics.lyrics_body;
var formattedLyrics = JSON.stringify(lyrics, null, 2);
var htmlFormatted = formattedLyrics.replace(/\n/g, "<br />");
var htmlFormatted2 = htmlFormatted.replace(/\"/g, "");
// console.log(htmlFormatted);
$("<p>" + htmlFormatted2 + "</p>").appendTo("#para1");
});
</script>
<div id="para1"></div>