This question already has answers here:
Answer
Solution:
First bind then execute
$startFrom = 0;
$perPage = 12;
$query = $db->prepare("SELECT * FROM products LIMIT ?,?");
$query->bind_param('ii', $startFrom, $perPage);
$query->execute();
$products = $query->fetchAll();
var_dump($products);
Source