title: Warning: PDOStatement::execute(): SQLSTATE[HY093]: Invalid parameter number: parameter was not defined in...filetext
body: <p>$fields is an array that after printing gets values like:</p>
  
  <pre><code>Array ( [first_name] =&gt; Nisse [last_name] =&gt; Example [ssn] =&gt; 198306205053 [address] =&gt;           Stockholm, Sverige [phone_number] =&gt; 54654987321546 [latitude] =&gt; 55.717089999999999 [longitude] =&gt; 13.235379 )
  </code></pre>
  
  <p>I call the update function from my dataclass like so:</p>
  
  <pre><code>DataManager::update_user($fields, $user_data['id'];
  </code></pre>
  
  <p>But I get the error: </p>
  
  <blockquote>
    <p>Warning: PDOStatement::execute(): SQLSTATE[HY093]: Invalid parameter number: parameter was not defined in...filetext</p>
  </blockquote>
  
  <p>I have checked several other similar threads but I guess I´m missing some basic concept here because I still can´t find the answer. There are 7 ?'s and 7 items in my array as far as I can see, and if I define all the values I can run it perfectly in SQL workbench, i.e.:</p>
  
  <pre><code>UPDATE users SET first_name = 'Kalle', last_name = 'Anka', ssn = 242345234, address = 'Stockholm', phone_number = 53423434, latitude = 17.189889231223423423424324234, longitude = 109.234234 WHERE id = 4
  </code></pre>
  
  <p>I have tried the PDO prepared statement both with the $user_id set to a specific value and also without the latitude/longitude parameters.</p>
  
  <p>If I have forgotten any critical information just point it out and I will get it. address is varchar and lat/long are floats in the DB btw. Using MYSQL.</p>
  
  <p>The function below:</p>
  
  <pre><code>public static function update_user($fields, $user_id)
  {
      $db = self::_connect();
  
      $st = $db-&gt;prepare("UPDATE users SET first_name = ?, last_name = ?, ssn = ?, address = ?, phone_number = ?, latitude = ?, longitude = ? WHERE id = '{$user_id}'");
      $st-&gt;execute($fields);
  
      return ($st-&gt;rowCount()) ? true : false;
  }
  </code></pre>