title: json_encode constantly returning null
body: <p>I'm trying to work with MySql and php to output json file. I've structured the query and json_encode and it's just working out. Tried reading forums and articles and tried various different things but nothing is bringing the result. I understand there's issue with the encoding, but despite trying so many things it still returns NULL.</p>
  
  <p>Here's the code:</p>
  
  <pre><code>&lt;?php require_once('Connections/db_con.php'); ?&gt;
  &lt;?php
  mysql_query('SET CHARACTER SET utf8');
  $result = mysql_query("SELECT 
  kkj_bsms_studies.studytext,
  kkj_bsms_studies.id, 
  kkj_bsms_studies.teacher_id, 
  kkj_bsms_studies.studytitle, 
  kkj_bsms_studies.studyintro,
  kkj_bsms_studies.media_hours, 
  kkj_bsms_studies.media_minutes, 
  kkj_bsms_studies.media_seconds, 
  kkj_bsms_teachers.teachername, 
  kkj_bsms_mediafiles.server, 
  kkj_bsms_mediafiles.`path`, 
  kkj_bsms_mediafiles.filename, 
  kkj_bsms_mediafiles.`size`, 
  kkj_bsms_servers.server_path, 
  kkj_bsms_folders.folderpath
  FROM kkj_bsms_studies, kkj_bsms_teachers, kkj_bsms_mediafiles,
  kkj_bsms_servers, kkj_bsms_folders
  WHERE series_id = 8 AND kkj_bsms_teachers.id =kkj_bsms_studies.teacher_id AND  kkj_bsms_mediafiles.study_id = kkj_bsms_studies.id AND kkj_bsms_servers.id =     kkj_bsms_mediafiles.server AND kkj_bsms_folders.id = kkj_bsms_mediafiles.path");  
  
  //Create an array
  $json_response = array();
  
  while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
  
      $row_array['hour'] = $row['kkj_bsms_studies.media_hours'];
  
      //push the values in the array
      array_push($json_response,$row_array);
  }
  echo json_encode($json_response);
  
  $error = json_last_error();
  echo $error;
  //Close the database connection
  fclose($db);
  ?&gt;
  </code></pre>
  
  <p>Thank you in advance for any help.</p>