Just working through some legacy code updating to PDO, I keep getting an error with the following code:
$p = $productsperpage*($currentpage-1);
$productsperpage = 1;
$stmt = $db->prepare("SELECT * FROM `products` LIMIT :start,:results");
$stmt->bindParam(':start', $p, PDO::PARAM_INT);
$stmt->bindParam(':results', $productperpage, PDO::PARAM_INT);
$stmt->execute();
The problem seems to be with the limit using bound parameters, please can anyone help with getting this working?
The error :
Warning: PDOStatement::execute(): SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''1'' at line 2 in /test/category.php on line 163
Thanks