I cannot seem to understand why I am getting error: mysqli_stmt::bind_param(): Number of variables doesn't match number of parameters in prepared statement
I followed this example:
Passing an array to a query using a WHERE clause
if you have any ideas that would be awesome!
$sql="SELECT pid,title,description,location FROM jobs WHERE status='o'";
if(isset($_POST['category'])){
$category_filter = join(',', array_fill(0, count($_POST['category']), '?'));
$sql .= " AND category IN ('.$category_filter.')";
}
$sql.="ORDER BY job_date DESC";
$stmt = $conn->prepare($sql);
$stmt->bind_param(str_repeat('s', count($_POST['category'])), ...$_POST['category']);
$stmt->execute();
$stmt->bind_result($pid,$title,$description,$location);