SET PDO::ATTR_EMULATE_PREPARES to false

PDO incorrectly creates the parameter for LIMIT-clauses as string. For the code

    $lim = 100;
    $stmt = $conn->prepare("SELECT * FROM users LIMIT ?");
    $result = $stmt->execute(array($lim))->fetch();

PDO will create the query

    SELECT * FROM users LIMIT '100'

which MySQL rejects because it is invalid. The easy solution is to set PDO::ATTR_EMULATE_PREPARES, then PDO won't insert the parameters in the query, instead it sends the query including the question marks to MySQL and transmits the parameter values separately.

Otherwise you would have to explicitly bind the value for each query, see http://stackoverflow.com/questions/18005593/parametrized-pdo-query-and-limit-clause-not-working