I'm trying to create a search feature on my website. It isn't showing any results and I keep getting `Call to a member function prepare() on a non-object in line x`...

```
function doSearch() {
    $output = '';
    if(isset($_POST['search'])) {
        $searchq = $_POST['search'];
        $searchq = preg_replace ("#[^0-9a-z]#i","",$searchq);
$sql = "SELECT * FROM entries WHERE name LIKE :searchq or description LIKE :searchq or content LIKE :searchq";

$stmt = $conn->prepare($sql);
$stmt->bindParam(":searchq",$searchq,PDO::PARAM_STR);
$stmt->execute();
$count = $stmt->rowCount();
 if($count == 0) {
            $output = '<tr><tr>No results found.</tr></td>';
        } else {
            while($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
                $eName = $row['name'];
                $eDesc = $row['description'];
                $eCont = $row['content'];
                $id = $row['id'];
                $elvl = $row['level'];
                $ehp = $row['hp'];

                $output .= '<tr><td><a href="http://xxxx.com/xxx?id=' .$id. '" onclick="document.linkform.submit();">'.$eName.'</a></td><td>'.$eDesc.'</td><td>'.$elvl.'</td><td>'.$ehp.'</td></tr>';
            }
        }            

    return $output;
    }
 }

```

I have my PDO connection included in my functions.php file.