title: Update data baseSQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens
body: <p>I am doing a php file when user is logged in and wants to update profile.</p>
  
  <p>I receive SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens.</p>
  
  <p>EditProfile.php</p>
  
  <pre><code>&lt;?php
  session_start();
  require_once 'class.user.php';
  $user_home = new USER();
  
  
  $stmt = $user_home-&gt;runQuery("SELECT * FROM registered_users WHERE userID=:uid");
  $stmt-&gt;execute(array(":uid"=&gt;$_SESSION['userSession']));
  $row = $stmt-&gt;fetch(PDO::FETCH_ASSOC);
  $_SESSION['email'] = $row['email'];
  ?&gt;
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
  &lt;head&gt;
  &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;
  &lt;title&gt;PHP Update Data From MySql - By Cleartuts&lt;/title&gt;
  &lt;link rel="stylesheet" href="style.css" type="text/css" /&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;center&gt;
  
  &lt;h1&gt;Edit Particulars&lt;/h1&gt;
  
  &lt;div id="body"&gt;
      &lt;div id="content"&gt;
      &lt;table align="center" width="100%"&gt;
  
  
              &lt;tr&gt;
              &lt;td&gt;Full Name&lt;/td&gt;
              &lt;td&gt;&lt;?php echo $row["fullName"]; ?&gt;&lt;/td&gt;
  
              &lt;/tr&gt;
              &lt;tr&gt;
              &lt;td&gt;Mobile Number&lt;/td&gt;
              &lt;td&gt;&lt;?php echo $row['mobileNumber']; ?&gt;&lt;/td&gt;
              &lt;/tr&gt;
  
              &lt;tr&gt;
              &lt;td&gt;Password&lt;/td&gt;
              &lt;td&gt;&lt;?php echo $row ['password']; ?&gt;&lt;/td&gt;
              &lt;/tr&gt;
  
              &lt;tr&gt;
              &lt;td&gt;Address&lt;/td&gt;
              &lt;td&gt;&lt;?php echo $row['address']; ?&gt;&lt;/td&gt;
              &lt;/tr&gt;
  
              &lt;tr&gt;
              &lt;td&gt;Postal Code&lt;/td&gt;
              &lt;td&gt;&lt;?php echo $row['postalCode']; ?&gt;&lt;/td&gt;
              &lt;/tr&gt;
  
              &lt;tr&gt;
              &lt;td&gt;Edit&lt;/td&gt;
              &lt;td&gt;&lt;a href="edit_data.php?edit_id=&lt;?php echo $row[0]; ?&gt;"&gt;&lt;img src="b_edit.png" alt="Edit" /&gt;&lt;/a&gt;&lt;/td&gt;
             &lt;/tr&gt;
  
      &lt;/table&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  
  
  &lt;/center&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>edit_data.php</p>
  
  <pre><code>&lt;?php
  session_start();
  require_once 'class.user.php';
  $user_home = new USER();
  $reg_user = new USER();
  
  $stmt = $user_home-&gt;runQuery("SELECT * FROM registered_users WHERE userID=:uid");
  $stmt-&gt;execute(array(":uid"=&gt;$_SESSION['userSession']));
  $row = $stmt-&gt;fetch(PDO::FETCH_ASSOC);
  $email=$_SESSION['email'];
  if(isset($_GET['edit_id']))
  {
      $stmt = $user_home-&gt;runQuery("SELECT * FROM registered_users WHERE userID=:uid".$_GET['edit_id']);
  
  
  }
  if(isset($_POST['btn-update']))
  {
      // variables for input data
  
      $fullName = $_POST['fullName'];
  
      $mobileNumber = $_POST['mobileNumber'];
  
      $password = $_POST['password'];
      $address = $_POST['address'];
      $postalCode = $_POST['postalCode'];
      // variables for input data
  
      // sql query for update data into database
  
          if($reg_user-&gt;updateUser($fullName,$mobileNumber,$password,$address,$postalCode,$email))
          {
  
              echo"good";
              ?&gt;
              &lt;script&gt;
              alert('Data Are Updated Successfully');
              window.location.href='home.php';
              &lt;/script&gt;
              &lt;?php 
          }
          else
          {
              echo "sorry ,Pleae go to nearest NPC to register.";
              ?&gt;
              &lt;script&gt;
              alert('error occured while updating data');
              &lt;/script&gt;
              &lt;?php 
          }
  
  
  
  }
  if(isset($_POST['btn-cancel']))
  {
      header("Location: home.php");
  }
  ?&gt;
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
  &lt;head&gt;
  &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;
  &lt;title&gt;PHP Update Data From MySql - By Cleartuts&lt;/title&gt;
  &lt;link rel="stylesheet" href="style.css" type="text/css" /&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;center&gt;
  
  &lt;div id="header"&gt;
      &lt;div id="content"&gt;
      &lt;label&gt;PHP PHP Update Data From MySql - By Cleartuts&lt;/label&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  &lt;div id="body"&gt;
      &lt;div id="content"&gt;
      &lt;form method="post"&gt;
      &lt;table align="center"&gt;
      &lt;tr&gt;
      &lt;td&gt;Full Name&lt;/td&gt;
      &lt;td&gt;&lt;input type="text" name="fullName" placeholder="full Name" value="&lt;?php echo $row['fullName']; ?&gt;" required /&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
      &lt;td&gt;Mobile Number&lt;/td&gt;
      &lt;td&gt;&lt;input type="text" name="mobileNumber" placeholder="mobile Number" value="&lt;?php echo $row['mobileNumber']; ?&gt;" required /&gt;&lt;/td&gt;
      &lt;/tr&gt;
  
      &lt;tr&gt;
      &lt;td&gt;Password&lt;/td&gt;
      &lt;td&gt;&lt;input type="password" name="password" placeholder="password" value="&lt;?php echo $row['password']; ?&gt;" required /&gt;&lt;/td&gt;
      &lt;/tr&gt;
  
      &lt;tr&gt;
      &lt;td&gt;Address&lt;/td&gt;
      &lt;td&gt;&lt;input type="text" name="address" placeholder="Blk 123 Ang Mo kio Ave 1 #12-112" value="&lt;?php echo $row['address']; ?&gt;" required /&gt;&lt;/td&gt;
      &lt;/tr&gt;
  
      &lt;tr&gt;
      &lt;td&gt;Postal Code&lt;/td&gt;
      &lt;td&gt;&lt;input type="text" name="postalCode" placeholder="123456" value="&lt;?php echo $row['postalCode']; ?&gt;" required /&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
      &lt;td&gt;
      &lt;button type="submit" name="btn-update"&gt;&lt;strong&gt;UPDATE&lt;/strong&gt;&lt;/button&gt;
      &lt;button type="submit" name="btn-cancel"&gt;&lt;strong&gt;Cancel&lt;/strong&gt;&lt;/button&gt;
      &lt;/td&gt;
      &lt;/tr&gt;
      &lt;/table&gt;
      &lt;/form&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  
  
  
  &lt;/center&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>fuction</p>
  
  <pre><code>public function updateUser($fullName,$mobileNumber,$password,$address,$postalCode,$email)
      {
          try
          {
  
              $password = md5($password);
              $stmt = $this-&gt;conn-&gt;prepare("UPDATE SET  registered_users (fullName=:fullName,mobileNumber=:mobileNumber,password=:password,address=:address,postalCode=:postalCode WHERE email=:email_id");
              $stmt-&gt;execute(array(":email_id"=&gt;$email));
              $userRow=$stmt-&gt;fetch(PDO::FETCH_ASSOC);
  
              $stmt-&gt;bindparam(":fullName",$fullName);
  
              $stmt-&gt;bindparam(":mobileNumber",$mobileNumber);
  
              $stmt-&gt;bindparam(":password",$password);
              $stmt-&gt;bindparam(":address",$address);
              $stmt-&gt;bindparam(":postalCode",$postalCode);
  
  
  
              $stmt-&gt;execute();
              return $stmt;
          }
          catch(PDOException $ex)
          {
              echo $ex-&gt;getMessage();
          }
      }
  </code></pre>