title: undenfined index, syntaxerror.json.parse
body: <p>the code below results me an error <code>Undefined index: id</code>   and results in a bigger error in the whole code <code>SyntaxError: JSON.parse: unexpected character</code> any ideas where i went wrong? It may seem a stupid question but I'm new to programming and there's so much things to know, so it's a bit hard to hang on at the start :)</p>
  
  <pre><code> protected function handle_file_upload($uploaded_file, $name, $size, $type, $error,
              $index = null, $content_range = null) {
          $file = parent::handle_file_upload(
              $uploaded_file, $name, $size, $type, $error, $index, $content_range
          );
          if (empty($file-&gt;error)) {
  $con = mysqli_connect("localhost","root","","login");
              $q1 = "SELECT MAX(id) FROM masinos";
              $res = mysqli_query($con,$q1);
              $row = mysqli_fetch_array($res);
  
              $max_id = $row["id"];
              $max_id_plus = $max_id + 1;
  
              $sql = "INSERT INTO files (`carID`,`name`, `size`, `type`, `title`, `description`)
                  VALUES($max_id_plus,?, ?, ?, ?, ?)";
              $query = $this-&gt;db-&gt;prepare($sql);
              $query-&gt;bind_param(
                  'sisss',
                  $file-&gt;name,
                  $file-&gt;size,
                  $file-&gt;type,
                  $file-&gt;title,
                  $file-&gt;description
              );
              $query-&gt;execute();
              $file-&gt;id = $this-&gt;db-&gt;insert_id;
          }
          return $file;
      }
  </code></pre>