I have the following error:
Uncaught PDOException: SQLSTATE[42000]: Syntax error or access violation: 1064 syntax error, unexpected '-'
This is the piece of code where it happens:
$stmt = $db->prepare(
"
SELECT
product_id,
name
FROM
products
WHERE
MATCH(name) AGAINST(:name IN BOOLEAN MODE)
"
);
$stmt->bindParam(':name',$name,PDO::PARAM_STR);
$stmt->execute();
The problem appears when name has a dash (-) in it. When the name is 'normal' (without a dash), it works.
I tried the solution in this question (PDO and UTF-8 Special characters in PHP / MySQL?) but that does not work.
Anyone an idea?
Thanks in advance!
Edit
@lonesomeday answer works, but I found another solution. By changing 'IN BOOLEAN MODE' to 'IN NATURAL LANGUAGE MODE', the error disappeared.