I am having an issue with PDO which I have seen discussed around but the different solutions provided did not work for me. It is when binding a number to set the LIMIT of a SQL query.
Here is the error I get:
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 ''2'' at line 1 in ...
The code:
$remaining = 3 - $countRows;
$con->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING );
$result4 = $con->prepare("SELECT * FROM item_descr WHERE id_item != ? LIMIT ?");
$result4->execute(array($itemId, intval($remaining)));