Sorry, I have just joined the forums but I’ve noticed the same error with the first look I threw at your code.
$tracks = "a simple variable";
If you want to store tracks, then you should declare it as an array.
$tracks = array();
// now you should fill the array with data within your loop like this
$tracks[] = "some value";
Remember, when you want to retrieve values, you need to loop through the $tracks