title: PHP PDO Prepared statement with REGEXP
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/12548926/php-prepared-statements-bind-variable-as-numeric-range-in-regexp">PHP Prepared Statements&hellip; Bind variable as numeric range in REGEXP?</a>  </p>
  </blockquote>
  
  
  
  <pre><code>$query = "SELECT * FROM `mytable` WHERE `file` REGEXP 'This string :var'";
  $stmt = $dbh-&gt;prepare($query);
  $stmt-&gt;bindValue(':var', 'exists');
  $stmt-&gt;execute();
  </code></pre>
  
  <p>This throws error:</p>
  
  <blockquote>
    <p>SQLSTATE[42000]: Syntax error or access violation</p>
  </blockquote>
  
  <p>When I echo $query before the execute, I get:</p>
  
  <pre><code>SELECT * FROM `mytable` WHERE `file` REGEXP 'This string :var'
  </code></pre>
  
  <p>How the hell do you bind variables in a regexp?</p>