I’m not sure if this a Db or a PHP issue. I am trying to perform a SELECT … LIKE with a prepared statement using SQLite and am having trouble with the % signs.
The following query works if the search term is entered in full
$query = "SELECT cid, mname FROM matters WHERE mname LIKE :find;"; $stmt = $db->prepare($query); $stmt->bindParam('find', $_POST['find'], PDO::PARAM_STR); $stmt->execute(); $result = $stmt->fetchAll();
but if I try
%:find% I get an error:
SQLSTATE[HY000]: General error: 1 near “%”: syntax error
and I get a similar error if I quote the %s - and if I have
SQLSTATE[HY000]: General error: 25 column index out of range.
My little brain is running out of ideas.