How to wrap a search value in wildcards for a LIKE condition in a parameterized query
01:18 02 Jun 2019

I am wanting to display selected info from a MySQL database with a SELECT columns WHERE column LIKE % ?, but I'm getting an error at the '%' symbol. Where must I insert the '%' symbol?

$query = 'SELECT 
                q.id, 
                q.id_user, 
                q.id_tag,
                q.image,
                q.title,
                q.description,
                q.like,
                q.dislike,
                q.date,
                q.status
               FROM
                '.$this->table.' as q
            WHERE
                q.title LIKE ?';

This is how I execute that:

$stmt = $this->conn->prepare($query);
$stmt->bindParam(1, $this->like);
$stmt->execute();

And this is how I request it:

$question->title = isset($_GET['title']) ? $_GET['title'] : die();
php mysql prepared-statement sql-like