I have a function that takes an SQL query and parameters/array of parameters. This function working fine on UPDATE statements but not on SELECT statements.The function mysqli_fetch_array is not returning anything and I cannot figure out why. The error message I am getting is;
"mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given"
I am using PHP version 5.5.
The query is as follows:
<?php
        $txtSearch = isset($_POST["txtSearch"]) ? $_POST["txtSearch"] : "";
            $result_search = null;
            $query = "";
            if(!empty($txtSearch))
            {
                if($page == "adverts")
                {
                    $query = "
                        SELECT
                            A.ID,
                            A.title,
                            A.productname,
                            A.price,
                            A.description,
                            A.productlocation,
                            (SELECT I.name FROM image I WHERE I.advertID = A.ID LIMIT 1) AS name
                        FROM advert A
                        WHERE A.title LIKE ?";
                }
                $result_search = queryDB($query, array("s", "%".$txtSearch."%"));
            }
           while($row = mysqli_fetch_array($result_search))
                {
                                                echo 
                                                    "<div class='post_container'>
                                                            <div class='title_banner'>".$row["title"]."</div>
                                                            <div>£".$row["price"]."</div>
                                                    </div>";
                                            }                           
        ?>