title: 502 Bad Gateway Error when using jQuery Ajax POST with php
body: <p>I am trying to send data to a database. Here is the method I am using:</p>
  
  <pre><code>&lt;script&gt;
  
  function add_new_activity(id) {
  
      var act_type = $("#add_new_activity #act_type").val();
      var act_muscles = $("#add_new_activity #multi").val();
      var act_location = $("#add_new_activity #act_location").val();
      var act_intensity = $("#add_new_activity #act_intensity").val();
      var act_length = $("#add_new_activity #timepicker").val();
      var act_content = $("#add_new_activity #textarea").val();                                                           
      if(act_type != "" &amp;&amp; act_muscles != "" &amp;&amp; act_location != ""  &amp;&amp; act_intensity != "" &amp;&amp; act_content != ""){
          $.ajax({
              type: "POST",
              url: "data.php",
              data: "page=profile&amp;add_new_activity=&lt;?php echo $user-&gt;user_id; ?&gt;&amp;act_type="+act_type+"&amp;act_muscles="+act_muscles+"&amp;act_location="+act_location+"&amp;act_intensity="+act_intensity+"&amp;act_length="+act_length+"&amp;act_content="+act_content,
              success: function(data){
                 location.reload();
              },
              beforeSend: function(){
                  $("#add_new_activity #add_act_button").html("&lt;?php echo $translate-&gt;_('adding'); ?&gt;...");
              }
          });
      } else {
          $("#add_new_activity #message").html("&lt;div class='alert alert-error'&gt;&lt;button type='button' class='close' data-dismiss='alert'&gt;&lt;/button&gt;&lt;?php echo $translate-&gt;_('required_field'); ?&gt;&lt;/div&gt;");
      }
  }
  &lt;/script&gt;
  </code></pre>
  
  <p>part of <strong><code>data.php</code></strong></p>
  
  <pre><code>if(isset($_POST['add_new_activity'])){
      $user_id = $_POST['add_new_activity'];
      $act_type = $_POST['act_type'];
      $act_muscles = $_POST['act_muscles'];
      $act_location = $_POST['act_location'];
      $act_intensity = $_POST['act_intensity'];
      $act_length = $_POST['act_length'];
      $act_content = $_POST['act_content'];                                                                                                                                           
      Profile::add_new_activity($user_id, $act_type, $act_muscles, $act_location, $act_intensity, $act_length, $act_content);}
  </code></pre>
  
  <p>part of <strong><code>Profile</code></strong> class</p>
  
  <pre><code>public static function add_new_activity($user_id, $act_type, $act_muscles, $act_location, $act_intensity, $act_length, $act_content,$user_id=""){
      global $database;
      global $translate;
  
      $datetime = strftime("%Y-%m-%d %H:%M:%S", time());
      $database-&gt;query("INSERT INTO activities (id,type,body,intensity,location,content,length,posted,user_id) VALUES ('','{$act_type}','{$act_muscles}','{$act_intensity}','{$act_location}','{$act_content}','{$act_length}','{$datetime}','{$user_id}') ");
  
  }
  </code></pre>
  
  <p>If I post a small amount of data everything is ok, but if I post a large amount I get this error:</p>
  
  <p><img src="https://i.stack.imgur.com/BLHN7.png" alt="enter image description here">
  <img src="https://i.stack.imgur.com/Q6vkl.png" alt="enter image description here">
  <img src="https://i.stack.imgur.com/z6o6n.png" alt="enter image description here"></p>
  
  <p><strong><code>server log:</code></strong></p>
  
  <pre><code>ip - - [17/Jan/2014:00:02:00 +0100] "POST /fitstats/data.php HTTP/1.1" 200 537 "http://ssbox.si/fitstats/profile.php?lang=en&amp;username=some1ell" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36"
  </code></pre>
  
  <p>How can I pass these error and successfully send data to mysql? </p>