title: Edit Form PHP PDO
body: <p>I have a table in SQL Server database. I created an "edit.php" where we can update the database. The database connection is established using PDO. </p>
  
  <p>I have a lot of <code>Null</code> values in the table. When I click "Edit" option, the form pops out. If I completely fill the records, the database gets updated. Otherwise I get this error message.</p>
  
  <blockquote>
    <p>SQLSTATE[42000]: [Microsoft][ODBC Driver 11 for SQL Server][SQL Server]Error converting data type nvarchar to numeric. </p>
  </blockquote>
  
  <p>The codes for my edit.php are included below:</p>
  
  <pre><code>require_once('database.php');
  if (isset($_POST['btn_submit'])) {
          $id = $_POST['txt_id'];
          $site = $_POST['txt_site_code'];
          $location = $_POST['txt_location_name'];
  
   try {
         $stmt = $conn-&gt;prepare("UPDATE MATRIX SET Site_Code=:site, Location_name=:location
  WHERE OBJECTID =:id");
  $stmt-&gt;execute(array(':site' =&gt; $site, ':location' =&gt; $location,':id' =&gt; $id));
  if ($stmt) {
  
  
                     header('Location:index.php');
  
                 }
               } catch (PDOException $e) {
                 echo $e-&gt;getMessage();
              }
  }
  
      $object_id = '';
      $site = '';
      $location = '';
  
   if (isset($_GET['id'])) {
          $id = $_GET['id'];
          $stmt = $conn-&gt;prepare("SELECT * FROM MATRIX WHERE OBJECTID=:id");
          $stmt-&gt;execute(array(':id' =&gt; $id));
          $row = $stmt-&gt;fetch();
          $object_id = $row['OBJECTID'];
          $site = $row['Site_Code'];
          $location = $row['Location_name'];
  }
  
  ?&gt;
      &lt;h2&gt;Edit the records&lt;/h2&gt;
  
      &lt;form action="" method="post"&gt;
          &lt;table border="3px" cellpadding="5px"&gt;
  
              &lt;tr&gt;
                  &lt;td&gt;Site Code&lt;/td&gt;
                  &lt;td&gt;&lt;input type="text" name="txt_site_code"  value="&lt;?= $site; ?&gt;"&gt;&lt;/td&gt;
              &lt;/tr&gt;
  
              &lt;tr&gt;
                  &lt;td&gt;Location Name&lt;/td&gt;
                  &lt;td&gt;&lt;input type="text" name="txt_location_name" value="&lt;?= $location; ?&gt;"&gt;&lt;/td&gt;
              &lt;/tr&gt;
  
               &lt;tr&gt;
                  &lt;td&gt;&lt;input type="hidden" name="txt_id" value="&lt;?= $object_id; ?&gt;"&gt;&lt;/td&gt;
                  &lt;td&gt;&lt;input type="submit" name="btn_submit" value="Submit"&gt;&lt;/td&gt;
              &lt;/tr&gt;
  
  &lt;/table&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>I would appreciate your efforts to help.</p>