0

Having issues implementing a like clause for the query below, it seems binding the parameters is interfering with the variable and ignoring the wildcards.

Have attempted the query manually by excluding the variable and it works fine. What is it I am doing wrong here? Below is my most recent attempt.

function blogSearch($search){
    global $conn;
    $search = "%".$search."%";
    $get_blog = $conn->prepare("SELECT * FROM posts WHERE post_tag LIKE ?");
    $get_blog->bindParam(1, $search, PDO::PARAM_STR, 40);
    $get_blog->execute();
    $result = $get_blog->fetchAll();
    return $result;
}
RiggsFolly
  • 93,638
  • 21
  • 103
  • 149
ababusa
  • 240
  • 2
  • 10

0 Answers0