title: Getting a 500 server error when POSTing to a PHP file
body: <p>So, I'm trying to work with a simple API parse, POST the data to a PHP file to save into a database.  My problem is there is a 500 server error surrounding the POST and I'm not sure what is going on.</p>
  
  <p><em>Failed to load resource: the server responded with a status of 500 (Internal Server Error)</em></p>
  
  <p>Here is view-deals.html, this file is where I grab data from API result:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
      &lt;head&gt;
          &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"&gt;&lt;/script&gt;
          &lt;?php
              require_once 'db_config.php';
              echo "vd-1";
              //mysql_query($sqlApiAccess) or die('Error, insert query failed');
          ?&gt;
          &lt;script type='text/javascript'&gt;
              $(function () {
                  var summonerId = '----------';
                  $.getJSON("----------" + ---------- + "/----------?", 
                  {
                      api_key: "----------"
                  }).done(function (data) {
                      console.log(data);
                      // do whatever processing you need to do to the data
  
                      $.post('save-deals.php', {dealData: data}, function(finishData) {
                           //This is an optional function for when it has finished saving
                      });
  
                      // Your formatting comes next
                  });
              });
          &lt;/script&gt;
      &lt;/head&gt;
      &lt;body&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Here is the save-deals.php file where I'm POSTing the data to, to save in the DB:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
     &lt;!--&lt;head&gt;
        &lt;?php
           require_once 'db_config.php';
           //mysql_query($sqlApiAccess) or die('Error, insert query failed');
        ?&gt;
     &lt;/head&gt;--&gt;
     &lt;body&gt;
        &lt;?php
           require_once 'db_config.php';
           ob_start(); //I like output-buffering because if we need to change headers mid script nothing dies
  
           $DealData = isset($_POST['dealData']) ? $_POST['dealData'] : die("Malformed form data!");
  
           if ($DealData!='') {
              $DealData = $DB-&gt;real_escape_string($DealData); //Sanitize it for MySQL
  
              if (!$DB-&gt;query("INSERT INTO deals(data) VALUES ($DealData)") {
                 echo "Insert failed: (" . $DB-&gt;errno . ") " . $DB-&gt;error;
              } else {
                 //AT THIS POINT IT SHOULD HAVE BEEN INSERTED!
                 //You could return a success string, or whatever you want now.
              }
           } else {
              http_response_code("400");
              die("Bad Request, please check your entry and try again");
           }
           ob_end_flush(); //Close up the output-buffer
  
        ?&gt;
     &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Here is the network result on view-deals.html page:</p>
  
  <p><a href="https://i.stack.imgur.com/SQ0tx.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/SQ0tx.png" alt="enter image description here"></a></p>
  
  <p>Here is the error on save-deals.php page:</p>
  
  <p><a href="https://i.stack.imgur.com/vtQhY.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/vtQhY.png" alt="enter image description here"></a></p>