title: Failing to update certain records in the database
body: <p>Well, for a good while I've now been stuck trying to figure out why most of my records are updating successfully while a certain few aren't. I've checked the php variable name/sql row names, ajax request and I don't see anything wrong. So here I am, hoping that someone can take a look at my code and help me figure out what's wrong.</p>
  
  <p><a href="https://i.stack.imgur.com/0cJOc.png" rel="nofollow noreferrer">Screenshot to show what I'm refering to.</a></p>
  
  <p>Html/JS:</p>
  
  <pre><code>&lt;div class="container"&gt;
      &lt;div class="page-header"&gt;
          &lt;h1&gt;General Reservation
              &lt;small&gt;Update, Delete&lt;/small&gt;
          &lt;/h1&gt;
      &lt;/div&gt;
  &lt;/div&gt;
      &lt;div class="row"&gt;
          &lt;div class="col-md-12"&gt;
              &lt;div class="container-fluid"&gt;
              &lt;table class="table table-bordered table-striped"&gt;
                  &lt;thead&gt;
                  &lt;tr&gt;
                      &lt;th&gt;Name&lt;/th&gt;
                      &lt;th&gt;Department/Group&lt;/th&gt;
                      &lt;th&gt;On-site Contact&lt;/th&gt;
                      &lt;th&gt;Phone&lt;/th&gt;
                      &lt;th&gt;Email&lt;/th&gt;
                      &lt;th&gt;Event Description&lt;/th&gt;
                      &lt;th&gt;Setup Time&lt;/th&gt;
                      &lt;th&gt;Number of Participants&lt;/th&gt;
                      &lt;th&gt;Date&lt;/th&gt;
                      &lt;th&gt;Start/End Time&lt;/th&gt;
                      &lt;th&gt;Special Accommodations&lt;/th&gt;
                      &lt;th&gt;Room&lt;/th&gt;
                      &lt;th&gt;Room Style&lt;/th&gt;
                      &lt;th&gt;Catering&lt;/th&gt;
                      &lt;th&gt;Technical Equipment&lt;/th&gt;
                      &lt;th&gt;Pre-Clean&lt;/th&gt;
                      &lt;th&gt;On-clean&lt;/th&gt;
                      &lt;th&gt;Post-Clean&lt;/th&gt;
                      &lt;th&gt;Reserved Parkning&lt;/th&gt;
                      &lt;th&gt;VIP&lt;/th&gt;
                      &lt;th&gt;Action&lt;/th&gt;
                  &lt;/tr&gt;
                  &lt;/thead&gt;
                  &lt;tbody&gt;
                  &lt;/tbody&gt;
              &lt;/table&gt;
          &lt;/div&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  
  &lt;script src="js/jquery.min.js"&gt;&lt;/script&gt;
  &lt;script src="js/bootstrap.min.js"&gt;&lt;/script&gt;
  &lt;script src="js/scripts.js"&gt;&lt;/script&gt;
  &lt;script&gt;
  function viewGenData(){
      $.ajax({
          type: "GET",
          url: "servergen.php",
          success: function(data){
              $('tbody').html(data);
          }
      });
  }
  function updateGenData(str){
      var id = str;
      var name = $('#name-'+str).val();
      var dptGroup = $('#dptgroup-'+str).val();
      var onSiteContact = $('#onsitecontact-'+str).val();
      var phone = $('#phone-'+str).val();
      var email = $('#email-'+str).val();
      var eventDesc = $('#eventdesc-'+str).val();
      var setUpTime = $('#setuptime-'+str).val();
      var numOfParticipants = $('#partcnum-'+str).val();
      var date = $('#date-'+str).val();
      var startEndTime = $('#startendtime-'+str).val();
      var specialAcc = $('#specialacc-'+str).val();
      var room = $('#room-'+str).val();
      var roomStyle = $('#roomstyle-'+str).val();
      var catering = $('#catering-'+str).val();
      var techEquip = $('#techequip-'+str).val();
      var preClean = $('#preclean-'+str).val();
      var postClean = $('#postclean-'+str).val();
      var onClean = $('#onclean-'+str).val();
      var rsvParking = $('#rsvparking-'+str).val();
      var vip = $('#vip-'+str).val();
  
      $.ajax({
          type: "POST",
          url: "servergen.php?p=edit",
          data: "name=" + name + "&amp;department=" + dptGroup + "&amp;contact=" + onSiteContact + "&amp;phone=" +
          phone + "&amp;email=" + email + "&amp;description=" + eventDesc + "&amp;setuptime=" + setUpTime + "&amp;numberofparticipants=" + numOfParticipants +
          "&amp;date=" + date + "&amp;startendtime=" + startEndTime + "&amp;specialacc=" + specialAcc + "&amp;room=" + room + "&amp;roomstyle=" + roomStyle +
          "&amp;catering=" + catering + "&amp;techequipment=" + techEquip + "&amp;preclean=" + preClean + "&amp;postclean=" + postClean + "&amp;onclean=" + onClean +
          "&amp;rsvparking=" + rsvParking + "&amp;vip=" + vip + "&amp;id=" + id,
          success: function(data){
              viewGenData();
          }
      });
  }
  function deleteGenData(str){
      var id = str;
      $.ajax({
          type: "GET",
          url: "servergen.php?p=del",
          data: "id="+id,
          success: function(data){
              viewGenData();
          }
      });
  }
  </code></pre>
  
  <p></p>
  
  <p>Php/mySQL:</p>
  
  <pre><code>&lt;?php
  include("db.php");
  
  $page = isset($_GET['p'])?$_GET['p']:'';
  
  if($page=='edit'){
  
  $id = $_POST['id'];
  $name = $_POST['name'];
  $dptGroup = $_POST['dptgroup'];
  $onSiteContact = $_POST['onsitecontact'];
  $phone = $_POST['phone'];
  $email = $_POST['email'];
  $eventDesc = $_POST['eventdesc'];
  $setUpTime = $_POST['setuptime'];
  $numOfParticipants = $_POST['partcnum'];
  $date = $_POST['date'];
  $startEndTime = $_POST['startendtime'];
  $specialAcc = $_POST['specialacc'];
  $room = $_POST['room'];
  $roomStyle = $_POST['roomstyle'];
  $catering = $_POST['catering'];
  $techEquip = $_POST['techequip'];
  $preClean = $_POST['preclean'];
  $postClean = $_POST['postclean'];
  $onClean = $_POST['onclean'];
  $rsvParking = $_POST['rsvparking'];
  $vip = $_POST['vip'];
  
  $stmt = $db-&gt;prepare("update reservations set req_name=?, dept_group=?, onsite_contact=?, phone_num=?, email=?, event_description=?, setup_time=?, num_participants=?, date=?, start_end_time=?, notes=?, room=?, room_style=?, catering=?, tech_equip=?, pre_clean=?, post_clean=?, on_clean=?, reserved_parking=?, vip=? where id=?");
  $stmt-&gt;bindParam(1,$name);
  $stmt-&gt;bindParam(2,$dptGroup);
  $stmt-&gt;bindParam(3,$onSiteContact);
  $stmt-&gt;bindParam(4,$phone);
  $stmt-&gt;bindParam(5,$email);
  $stmt-&gt;bindParam(6,$eventDesc);
  $stmt-&gt;bindParam(7,$setUpTime);
  $stmt-&gt;bindParam(8,$numOfParticipants);
  $stmt-&gt;bindParam(9,$date);
  $stmt-&gt;bindParam(10,$startEndTime);
  $stmt-&gt;bindParam(11,$specialAcc);
  $stmt-&gt;bindParam(12,$room);
  $stmt-&gt;bindParam(13,$roomStyle);
  $stmt-&gt;bindParam(14,$catering);
  $stmt-&gt;bindParam(15,$techEquip);
  $stmt-&gt;bindParam(16,$preClean);
  $stmt-&gt;bindParam(17,$postClean);
  $stmt-&gt;bindParam(18,$onClean);
  $stmt-&gt;bindParam(19,$rsvParking);
  $stmt-&gt;bindParam(20,$vip);
  $stmt-&gt;bindParam(21,$id);
  if($stmt-&gt;execute()){
      echo "Success, data updated.";
  } else{
      echo "Failed, dated not updated.";
  }
  } else if($page=='del'){
  $id = $_GET['id'];
  $stmt = $db-&gt;prepare("delete from reservations where id=?");
  $stmt-&gt;bindParam(1, $id);
  if($stmt-&gt;execute()){
      echo "Success, data deleted.";
  } else{
      echo "Failed to delete data.";
  }
  } else{
  $stmt = $db-&gt;prepare("select * from reservations order by id desc");
  $stmt-&gt;execute();
  while($row = $stmt-&gt;fetch()){
      ?&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;?php echo $row['req_name']?&gt;&lt;/td&gt;
          &lt;td&gt;&lt;?php echo $row['dept_group']?&gt;&lt;/td&gt;
          &lt;td&gt;&lt;?php echo $row['onsite_contact']?&gt;&lt;/td&gt;
          &lt;td&gt;&lt;?php echo $row['phone_num']?&gt;&lt;/td&gt;
          &lt;td&gt;&lt;?php echo $row['email'] ?&gt;&lt;/td&gt;
          &lt;td&gt;&lt;?php echo $row['event_description'] ?&gt;&lt;/td&gt;
          &lt;td&gt;&lt;?php echo $row['setup_time']?&gt;&lt;/td&gt;
          &lt;td&gt;&lt;?php echo $row['num_participants']?&gt;&lt;/td&gt;
          &lt;td&gt;&lt;?php echo $row['date']?&gt;&lt;/td&gt;
          &lt;td&gt;&lt;?php echo $row['start_end_time']?&gt;&lt;/td&gt;
          &lt;td&gt;&lt;?php echo $row['notes']?&gt;&lt;/td&gt;
          &lt;td&gt;&lt;?php echo $row['room']?&gt;&lt;/td&gt;
          &lt;td&gt;&lt;?php echo $row['room_style']?&gt;&lt;/td&gt;
          &lt;td&gt;&lt;?php echo $row['catering']?&gt;&lt;/td&gt;
          &lt;td&gt;&lt;?php echo $row['tech_equip']?&gt;&lt;/td&gt;
          &lt;td&gt;&lt;?php echo $row['pre_clean']?&gt;&lt;/td&gt;
          &lt;td&gt;&lt;?php echo $row['post_clean']?&gt;&lt;/td&gt;
          &lt;td&gt;&lt;?php echo $row['on_clean']?&gt;&lt;/td&gt;
          &lt;td&gt;&lt;?php echo $row['reserved_parking']?&gt;&lt;/td&gt;
          &lt;td&gt;&lt;?php echo $row['vip']?&gt;&lt;/td&gt;
          &lt;td&gt;
              &lt;button class="btn btn-warning" data-toggle="modal" data-target="#edit-&lt;?php echo $row['id'] ?&gt;"&gt;Update&lt;/button&gt;
              &lt;!-- Modal --&gt;
              &lt;div class="modal fade" id="edit-&lt;?php echo $row['id'] ?&gt;" tabindex="-1" role="dialog" aria-labelledby="editLabel-&lt;?php echo $row['id'] ?&gt;"&gt;
                  &lt;div class="modal-dialog" role="document"&gt;
                      &lt;div class="modal-content"&gt;
                          &lt;div class="modal-header"&gt;
                              &lt;button type="button" class="close" data-dismiss="modal" aria-label="Close"&gt;&lt;span aria-hidden="true"&gt;&amp;times;&lt;/span&gt;&lt;/button&gt;
                              &lt;h4 class="modal-title" id="editLabel-&lt;?php echo $row['id'] ?&gt;"&gt;Update Data&lt;/h4&gt;
                          &lt;/div&gt;
                          &lt;form&gt;
                              &lt;div class="modal-body"&gt;
                                  &lt;input type="hidden" id="&lt;?php echo $row['id'] ?&gt;" value="&lt;?php echo $row['id'] ?&gt;"&gt;
                                  &lt;div class="form-group"&gt;
                                      &lt;label for="name-"&gt;Name of Requestor &lt;/label&gt;
                                      &lt;input type="text" class="form-control" id="name-&lt;?php echo $row['id'] ?&gt;" value="&lt;?php echo $row['req_name'] ?&gt;" /&gt;
                                  &lt;/div&gt;
                                  &lt;div class="form-group"&gt;
                                      &lt;label for="phone-"&gt;Phone Number&lt;/label&gt;
                                      &lt;input type="tel" class="form-control" id="phone-&lt;?php echo $row['id'] ?&gt;" value="&lt;?php echo $row['phone_num'] ?&gt;""  /&gt;
                                  &lt;/div&gt;
                                  &lt;div class="form-group"&gt;
                                      &lt;label for="setuptime-"&gt;Facilities/Catering Set-up time
                                          &lt;/label&gt;
                                      &lt;input type="text" class="form-control" id="setuptime-&lt;?php echo $row['id'] ?&gt;" value="&lt;?php echo $row['setup_time'] ?&gt;" /&gt;
                                  &lt;/div&gt;
                                  &lt;div class="form-group"&gt;
                                      &lt;label for="dptgroup-"&gt;Department/Group&lt;/label&gt;
                                      &lt;input type="text" class="form-control" id="dptgroup-&lt;?php echo $row['id'] ?&gt;" value="&lt;?php echo $row['dept_group'] ?&gt;" /&gt;
                                  &lt;/div&gt;
                                  &lt;div class="form-group"&gt;
                                      &lt;label for="email-"&gt;Email Address&lt;/label&gt;
                                      &lt;input type="email" class="form-control" id="email-&lt;?php echo $row['id'] ?&gt;" value="&lt;?php echo $row['email'] ?&gt;" /&gt;
                                  &lt;/div&gt;
                                  &lt;div class="form-group"&gt;
                                      &lt;label for="partcnum-"&gt;Number of Participants&lt;/label&gt;
                                      &lt;input type="text" class="form-control" id="partcnum-&lt;?php echo $row['id'] ?&gt;" value="&lt;?php echo $row['num_participants'] ?&gt;" /&gt;
                                  &lt;/div&gt;
                                  &lt;div class="form-group"&gt;
                                      &lt;label for="onsitecontact-"&gt;On-site Contact&lt;/label&gt;
                                      &lt;input type="text" class="form-control" id="onsitecontact-&lt;?php echo $row['id'] ?&gt;" value="&lt;?php echo $row['onsite_contact'] ?&gt;" /&gt;
                                  &lt;/div&gt;
                                  &lt;div class="form-group"&gt;
                                      &lt;label for="eventdesc-"&gt;Description of the Event&lt;/label&gt;
                                      &lt;textarea id="eventdesc-&lt;?php echo $row['id'] ?&gt;" class="form-control" rows="5" cols="25" value="&lt;?php echo $row['event_description'] ?&gt;"&gt;&lt;?php echo $row['event_description']?&gt;&lt;/textarea&gt;
                                  &lt;/div&gt;
                                  &lt;div class="form-group"&gt;
                                      &lt;label for="date-"&gt;Date&lt;/label&gt;
                                      &lt;input type="text" class="form-control" id="date-&lt;?php echo $row['id'] ?&gt;" value="&lt;?php echo $row['date'] ?&gt;"  /&gt;
                                  &lt;/div&gt;
                                  &lt;div class="form-group"&gt;
                                      &lt;label for="startendtime-"&gt;Start/End Time (AM/PM)&lt;/label&gt;
                                      &lt;input type="text" class="form-control" id="startendtime-&lt;?php echo $row['id'] ?&gt;" value="&lt;?php echo $row['start_end_time'] ?&gt;"  /&gt;
                                  &lt;/div&gt;
                                  &lt;div class="form-group"&gt;
                                      &lt;label for="specialacc-"&gt;Special accommodations, notes or additional requirements&lt;/label&gt;
                                      &lt;textarea id="specialacc-&lt;?php echo $row['id'] ?&gt;" class="form-control" rows="5" cols="25" value="&lt;?php echo $row['notes'] ?&gt;"&gt;&lt;?php echo $row['notes']?&gt;&lt;/textarea&gt;
                                  &lt;/div&gt;
  
                                  &lt;div class="form-group"&gt;
                                      &lt;label for="catering-"&gt;Is catering needed?&lt;/label&gt;
                                      &lt;input type="text" class="form-control" id="catering-&lt;?php echo $row['id'] ?&gt;" value="&lt;?php echo $row['catering'] ?&gt;"  /&gt;
                                  &lt;/div&gt;
                                  &lt;div class="form-group"&gt;
                                      &lt;label for="techequip-"&gt;Is technical equipment needed?&lt;/label&gt;
                                      &lt;input type="text" class="form-control" id="techequip-&lt;?php echo $row['id'] ?&gt;" value="&lt;?php echo $row['tech_equip'] ?&gt;"  /&gt;
                                  &lt;/div&gt;
                                  &lt;div class="form-group"&gt;
                                      &lt;label for="preclean-"&gt;Is pre-clean up needed?&lt;/label&gt;
                                      &lt;input type="text" class="form-control" id="preclean-&lt;?php echo $row['id'] ?&gt;" value="&lt;?php echo $row['pre_clean'] ?&gt;"  /&gt;
                                  &lt;/div&gt;
                                  &lt;div class="form-group"&gt;
                                      &lt;label for="onclean-"&gt;Is clean up during the event needed?&lt;/label&gt;
                                      &lt;input type="text" class="form-control" id="onclean-&lt;?php echo $row['id'] ?&gt;" value="&lt;?php echo $row['on_clean'] ?&gt;"  /&gt;
                                  &lt;/div&gt;
                                  &lt;div class="form-group"&gt;
                                      &lt;label for="postclean-"&gt;Is post clean up needed?&lt;/label&gt;
                                      &lt;input type="text" class="form-control" id="postclean-&lt;?php echo $row['id'] ?&gt;" value="&lt;?php echo $row['post_clean'] ?&gt;"  /&gt;
                                  &lt;/div&gt;
                                  &lt;div class="form-group"&gt;
                                      &lt;label for="rsvparking-"&gt;Is reserved parking needed?&lt;/label&gt;
                                      &lt;input type="text" class="form-control" id="rsvparking-&lt;?php echo $row['id'] ?&gt;" value="&lt;?php echo $row['reserved_parking'] ?&gt;"  /&gt;
                                  &lt;/div&gt;
                                  &lt;div class="form-group"&gt;
                                      &lt;label for="vip"&gt;Will there be a very important person will be in attendance (dignitaries, elected officials, high profile)?&lt;/label&gt;
                                      &lt;input type="text" class="form-control" id="vip-&lt;?php echo $row['id'] ?&gt;" value="&lt;?php echo $row['vip'] ?&gt;" /&gt;
                                  &lt;/div&gt;
                              &lt;/div&gt;
                              &lt;div class="modal-footer"&gt;
                                  &lt;button type="button" class="btn btn-default" data-dismiss="modal"&gt;Close&lt;/button&gt;
                                  &lt;button type="submit" onclick="updateGenData(&lt;?php echo $row['id'] ?&gt;)" class="btn btn-primary"&gt;Update&lt;/button&gt;
                              &lt;/div&gt;
                          &lt;/form&gt;
                      &lt;/div&gt;
                  &lt;/div&gt;
              &lt;/div&gt;
              &lt;button onclick="deleteGenData(&lt;?php echo $row['id'] ?&gt;)" class="btn btn-danger" style="width: 73.94px; margin-top: 2px"&gt;Delete&lt;/button&gt;
          &lt;/td&gt;
      &lt;/tr&gt;
      &lt;?php
  }
  }
  ?&gt;
  </code></pre>