I'm trying to use an array in my mysql query, when I use my variable holding the array it returns no results, as well as no errors.
$location = array("Cornwall", "Devon", "Dorset", "Norfolk & Suffolk", "Somerset", "Wiltshire");
//Query
$sql=$conn->prepare("SELECT * FROM adverts WHERE location IN (:location) AND status = 2 ORDER BY ref LIMIT :limit OFFSET :start");
$sql->bindValue(':location', implode(",", $location), PDO::PARAM_STR);
$sql->bindValue(':limit', (int) $limit, PDO::PARAM_INT);
$sql->bindValue(':start', (int) $start, PDO::PARAM_INT);
$sql->execute();
$adverts=$sql->fetchAll();
This returns no errors no results but the query does work if I hard code the values in such as:
$sql=$conn->prepare("SELECT * FROM adverts WHERE location IN ('Cornwall', 'Devon') ");