I tried to use CAST(column_name AS BINARY) in a PDO SELECT query and got a syntax error "PHP Parse error". I think the problem is in the last statement but do not know how to fix it. What should I do to correct this error?
DB:
tblrecord (firstname, lastname, score)
PHP:
$firstname = trim('Mary');
$lastname = trim('Lamb');
$sql = "SELECT * FROM tblrecord WHERE CAST(TRIM(firstname) AS BINARY) = ? AND CAST(TRIM(lastname) AS BINARY) = ?";
$stmt = $connection->prepare($sql);
$stmt->execute( array( CAST($firstname AS BINARY), CAST($lastname AS BINARY) ) );