In PDO today was the first time I had to by a variable in LIMIT, and I'm getting this error:
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE [HY093]: Invalid parameter number: number of bound variables does not match the number of tokens filename.php: 85 Stack trace: # 0 filename.php (85): PDOStatement-> Run (Array) # 1 {main} thrown in filename.php on line 85
Line 85 is this:
$sql2->execute(array(":idQuiz" => $idQuiz));
My code:
$perguntaQuiz = 2;
$sql2 = $pdo->prepare('SELECT * FROM quiz_pergunta WHERE idquiz = :idQuiz ORDER BY id ASC LIMIT 0, :perguntaQuiz');
$sql2->bindParam(':perguntaQuiz', $perguntaQuiz, PDO::PARAM_INT);
$sql2->execute(array(":idQuiz" => $idQuiz));
What am I missing?