title: PDO not insert some values but insert others
body: <p>This is what I have </p>
  
  <pre><code>&lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;
  
  &lt;?php 
  
  include_once("../conexao.php");
  include_once("../check_session.php");
  include_once("../set.php");
  $username = $_SESSION["username"];
  
  
   $profileimage =  $username.'.png';
   //echo $profileimage;
  
  //assign post vars 
  
  $post_name = $_POST['loginname'];
  $post_surname = $_POST['loginsurname'];
  $post_description = $_POST['profiledescription'];
  $post_local = $_POST['local'];
  $post_streetnumber = $_POST['streetnumber'];
  $post_streetaddress = $_POST['streetaddress'];
  $post_city = $_POST['city'];
  $post_state = $_POST['state'];
  $post_postalcode = $_POST['postalcode'];
  $post_country = $_POST['country'];
  $post_addressreference = $_POST['addressreference'];
  
  //variavel $conexao_pdo
  
  $sql1 = "SELECT * FROM user WHERE username = :usr";
  
                      //db column and value
          $stmt1 = $conexao_pdo-&gt;prepare($sql1);  
          //where clause                                 
          $stmt1-&gt;bindParam(':usr', $username);
          $stmt1-&gt;execute();  
          while ($linha = $stmt1-&gt;fetch(PDO::FETCH_OBJ)) {
    //echo $linha-&gt;name . ' - ' . $linha-&gt;email;
    $col_name = $linha-&gt;name;
    $col_surname = $linha-&gt;surname;
    //$col_email = $linha-&gt;email;
    $col_description = $linha-&gt;description;
    //$col_profileimage = $linha-&gt;profileimage;
    $col_local = $linha-&gt;local;
    $col_streetnumber = $linha-&gt;streetnumber;
    $col_streetaddress = $linha-&gt;streetaddress;
    $col_city = $linha-&gt;city;
    $col_state = $linha-&gt;state;
    $col_postalcode = $linha-&gt;postalcode;
    $col_country = $linha-&gt;country;
    $col_addressreference = $linha-&gt;addressreference;
  }
  
  $stringsize = strlen($post_description);
  
  if(empty($post_name)){ $name = $col_name;  } else { $name = $post_name; }
  if(empty($post_surname)){ $surname = $col_surname;  } else { $surname = $post_surname; }
  
  
  if(!empty($post_description) &amp;&amp; ($stringsize &lt;= 150)){ $description = $post_description;  } else { $description = $col_description; }
  
  
  
  if(empty($post_local)){ $local =  $col_local;  } else { $local = $post_local; }
  if(empty($post_streetnumber)){ $streetnumber =  $col_streetnumber;  } else { $streetnumber = $post_streetnumber; }
  if(empty($post_streetaddress)){ $streetaddress =  $col_streetaddress;  } else { $streetaddress = $post_streetaddress; }
  if(empty($post_city)){ $city =  $col_city;  } else { $city = $post_city; }
  if(empty($post_state)){ $state =  $col_state;  } else { $state = $post_state; }
  if(empty($post_postalcode)){ $postalcode =  $col_postalcode;  } else { $postalcode = $post_postalcode; }
  if(empty($post_country)){ $country =  $col_country;  } else { $country = $post_country; }
  if(empty($post_addressreference)){ $addressreference =  $col_addressreference;  } else { $addressreference = $post_addressreference; }
  
  
  
  $sql = "UPDATE user SET name = :name, 
              surname = :surname, 
              description = :description,  
              profileimage = :profileimage,  
              local = :local,
              streetnumber = :streetnumber,
              streetaddress = :streetaddress, 
              city = :city, 
              state = :state, 
              postalcode = :postalcode, 
              country = :country, 
              addressreference = :addressreference
              WHERE username = :username";
  
              //db column and value 
  $stmt = $conexao_pdo-&gt;prepare($sql);  
  //where clause                                 
  $stmt-&gt;bindParam(':username', $username);  
  $stmt-&gt;bindParam(':name', $name);    
  $stmt-&gt;bindParam(':surname', $surname);
  $stmt-&gt;bindParam(':description', $description); 
  $stmt-&gt;bindParam(':profileimage', $profileimage); 
  $stmt-&gt;bindParam(':local', $local); 
  $stmt-&gt;bindParam(':streetnumber', $streetnumber); 
  $stmt-&gt;bindParam(':streetaddress', $streetaddress); 
  $stmt-&gt;bindParam(':city', $city); 
  $stmt-&gt;bindParam(':state', $state); 
  $stmt-&gt;bindParam(':postalcode', $postalcode); 
  $stmt-&gt;bindParam(':country', $country); 
  $stmt-&gt;bindParam(':addressreference', $addressreference); 
  
  $stmt-&gt;execute();
  //sucess 
      echo "&lt;span style='color: green;' class='fa fa-check fa-3x' aria-hidden='true'&gt;&lt;/span&gt; "; 
  
  
   ?&gt;
  </code></pre>
  
  <p>This is what I am trying to do if input field is empty it will update with The current values that are in the db column, but it input it not empty it will update with the $_POST['vars'] assigned to the fields</p>
  
  <p>I am sending two form at once via jQuery in the form page </p>
  
  <pre><code>&lt;script src="https://code.jquery.com/jquery-3.2.1.min.js"&gt;&lt;/script&gt;
      &lt;button class="btn btn-primary" id="sendforms"&gt;submit&lt;/button&gt;
               &lt;div id="result"&gt; &lt;/div&gt;
              &lt;script type="text/javascript"&gt;
              $(document).ready(function () {
                $("#sendforms").click(function() {
                         var combinedFormData = $("#form1,#form3").serialize();
                       $.post(
                              "ok.php",
                              combinedFormData
                       ).done(function(data) {
                              //alert("Successfully submitted!");
                              $("#result").html(data);
                       }).fail(function () {
                                //alert("Error submitting forms!");
                       })
                });
              });
          &lt;/script&gt;
  </code></pre>
  
  <p>It's all working if I echo the <code>$_POST['vars']</code>;</p>
  
  <p>The problem is that pdo is not updating the second form with id="form3" I don't know why I know it's not a post problem because I tested it, it's a PDO issue.</p>
  
  <p>Apache last error log:</p>
  
  <pre><code>Access: `127.0.0.1 - - [24/Apr/2017:16:48:48 -0300] "-" 408 - "-" "-"`
  </code></pre>
  
  <p>error</p>
  
  <pre><code>[Mon Apr 24 16:35:23.680683 2017] [:error] [pid 6096:tid 1764] [client 127.0.0.1:51396] PHP Notice:  Undefined index: addressreference
  </code></pre>
  
  <p>for some reason the post index name it's shown as a error </p>
  
  <p>On post via jQuery I got a url like this : <code>index.php?loginname=&amp;loginsurname=&amp;profiledescription=</code> very weird because It's a post request not get also the jquery should be posting in the ok.php page but it shows this parameter in the url after post</p>
  
  <p>Here is the image when I perform an ajax call </p>
  
  <p><a href="https://i.stack.imgur.com/nvqnY.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/nvqnY.jpg" alt="enter image description here"></a></p>
  
  <p>I think it's probably a problem with PDO query limit size is there a way where I can increase it ?</p>
  
  <p>By my experience before I had a problem with pdo to insert in db a checkbox value it's not the case in this question but may help us to find what is wrong With PDO.</p>
  
  <p>When I retrieve error info from PDO </p>
  
  <pre><code>echo $conexao_pdo-&gt;errorInfo();
  </code></pre>
  
  <p>It returns to me <code>Array</code> </p>
  
  <p>using print_r </p>
  
  <pre><code>Array ( [0] =&gt; 00000 [1] =&gt; [2] =&gt; ) 
  </code></pre>
  
  <p>Using var_dump </p>
  
  <pre><code>array(3) { [0]=&gt; string(5) "00000" [1]=&gt; NULL [2]=&gt; NULL } 
  </code></pre>
  
  <p>I check if it's executed with success and it's </p>
  
  <pre><code>if ($stmt-&gt;execute()) {
    $_SESSION['result'] = "ok";
  } else {
  
      $_SESSION['result'] = "not ok";
  }
  </code></pre>
  
  <p>It's getting ok result but yet not saving into db</p>