In my MSQL table, one row has the column code as "1001000181026".
My PHP script is only interested in the bold part (1810), and I use the underscore wildcards (_) for the other characters of code.
But: It doesn't work with PDO (0 results)! On the other hand, if I write the SELECT
code manually into phpMyAdmin, it works well (1 result).
Here is the PDO/PHP-code (which is not working):
$code = '_______1810__';
$preparequery = 'SELECT * FROM table WHERE code LIKE :code';
$stmt = $conn->prepare($preparequery);
$stmt->bindValue("code", $code);
$y = $stmt->rowCount();
echo '<p>We have '.$y.' row(s).</p>'; // We have 0 row(s).
The query in phpMyAdmin works fine:
SELECT * FROM `table` WHERE code LIKE '_______1810__'
This gives me 1 result, as expected.
What could be wrong with the PHP code (PDO)? Thank you for your help!