$query = "SELECT * FROM `mytable` WHERE `file` REGEXP '[:val-9]'";
$stmt = $dbh->prepare($query);
$stmt->bindValue(':val', '1'); //I have also tried 1 without quotes
$stmt->execute();
Throws this error:
Syntax error or access violation: 1139 Got error 'invalid character range' from regexp
Is it possible to do this..
Placeholders can only be used where a value can appear, not embedded in strings. Try:
$query = "SELECT * FROM `mytable` WHERE `file` REGEXP CONCAT('[', :val, '-9]')";
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With