title: PHP pdo: Invalid Parameter Number when using a parameter twice?
body: <p>I have the Problem, that I can not use an SQL-Statement in PDO (PHP/mysql), when I use a positional parameter twice:</p>
  
  <pre><code>SELECT `ID` FROM `_LOGIN_` WHERE `LoginName` = :loginName AND `sha512`= SHA2(CONCAT(:pw, (SELECT `salt` FROM `_LOGIN_` WHERE `LoginName` = :loginName)), 512)
  </code></pre>
  
  <p>As you can see, I use ":loginName" twice. So the following error message appears:</p>
  
  <pre><code>PHP Fatal error:  Uncaught PDOException: SQLSTATE[HY093]: Invalid parameter number in ...
  </code></pre>
  
  <p>Am I missing something or is there another way to prepare the statement, so I can use parameters multiple times?</p>
  
  <p>Here follows the complete code to reproduce:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
    &lt;head&gt;
      &lt;title&gt;pdo&lt;/title&gt;   
  
      &lt;meta   charset = "utf-8" /&gt;
    &lt;/head&gt;
  
    &lt;body&gt;
        &lt;h1&gt;PDO Prepare&lt;/h1&gt;
  
        &lt;!--
        DB:
  
  DROP   DATABASE IF EXISTS `pdoTestDB`;
  CREATE DATABASE           `pdoTestDB`;
  ALTER  DATABASE           `pdoTestDB` DEFAULT CHARACTER SET 'utf8' DEFAULT COLLATE 'utf8_general_ci';
  
  CREATE TABLE `_LOGIN_` (
   `ID`           int(11)      NOT NULL
  ,`LoginName`    TEXT         NOT NULL 
  ,`SALT`         varchar(  6) NOT NULL 
  ,`sha512`       varchar(128) NOT NULL 
  ,`registerTS`   TIMESTAMP    NOT NULL DEFAULT CURRENT_TIMESTAMP 
  ,`lastLoginTS`  TIMESTAMP    NOT NULL DEFAULT CURRENT_TIMESTAMP 
  , PRIMARY KEY (`ID`)
  ) ;
  
  SELECT @SALT:=SUBSTRING(MD5(RAND()) FROM 1 FOR 6);
  
  INSERT INTO `_LOGIN_`
  (`ID`, `LoginName`, `salt`, `sha512`                                     , `registerTS`         ) VALUES
  (   1, 'muma'      , @SALT, SHA2(CONCAT('123', @SALT), 512), '2018-06-04'         );
        --&gt;
  
  &lt;?php
  $PDOcharset = 'utf8mb4';
  // set data source name:
  $dsn = "mysql:host=localhost;dbname=pdoTestDB;charset=$PDOcharset";
  $opt = [
      PDO::ATTR_ERRMODE            =&gt; PDO::ERRMODE_EXCEPTION,
      PDO::ATTR_DEFAULT_FETCH_MODE =&gt; PDO::FETCH_ASSOC,
      PDO::ATTR_EMULATE_PREPARES   =&gt; false,
  ];
  $pdo = new PDO($dsn, "santisPHP", "123", $opt);
  
  // the sql
  $sql = "SELECT `ID` FROM `_LOGIN_` WHERE `LoginName` = :loginName AND `sha512`= SHA2(CONCAT(:pw, (SELECT `salt` FROM `_LOGIN_` WHERE `LoginName` = :loginName)), 512)";
  
  $stmt = $pdo-&gt;prepare($sql);
  
  $paramsAssoc = ['loginName' =&gt; "muma", 'pw' =&gt; "123"];
          //echo $paramsAssoc;
  var_dump($stmt);
  var_dump($paramsAssoc);
  
  $result = $stmt-&gt;execute($paramsAssoc);
  
  $fetched = $stmt-&gt;fetch();
  
  echo "stmt: ";
  var_dump($stmt);
  echo "&lt;br /&gt;";
  
  echo "result: ";
  var_dump($result);
  echo "&lt;br /&gt;";
  
  echo "fetched: ";
  var_dump($fetched);
  echo "&lt;br /&gt;";
  ?&gt;
  
    &lt;/body&gt;
  
  &lt;/html&gt;
  </code></pre>