I am having an issue with a JSON web service I created with php. Keep getting garbage within my JSON when I include the line echo $_GET['jsoncallback'].'('.json_encode($posts).')'; added to that am getting an error unidentified index on line (some number) but its the line that echo $_GET['jsoncallback'].'('.json_encode($posts).')'; appears.

If i leave that line out I get JSON but end up with an error of invalid label

how can I solve this issue? My code is below

Code:
<?php
$link = mysql_connect('localhost','root','') or die('Cannot connect to the DB');
  mysql_select_db('music_db',$link) or die('Cannot select the DB');

  /* grab the posts from the db */
  $query = "SELECT track.track_id, track.track_name, artist.artist_name, genre.genre_name FROM artist INNER JOIN (genre INNER JOIN track ON genre.genre_id = track.genre_id) ON artist.artist_id = track.artist_id";
  $result = mysql_query($query,$link) or die('Errant query:  '.$query);

  /* create one master array of the records */
  $posts = array();
  if(mysql_num_rows($result)) {
    while($post = mysql_fetch_assoc($result)) {
      $posts[] = array('post'=>$post);
    }
  }

  /* output in necessary format */
  header('Content-type: application/json');
  echo $_GET['jsoncallback'];
  echo "(" . json_encode($posts) . ")";
@mysql_close($link);
?>