I'm writing a pagination script which while leaving irrelevant details for now goes like this:
$starting_limit = ($page-1)*$limit;
$show = "SELECT * FROM company ORDER BY id ASC LIMIT :starting_limit, :limit";
$r = $pdo->prepare($show);
$r->execute(array(':starting_limit' => $starting_limit, ':limit' => $limit));
And when I run it, I get an error:
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42000]:
Syntax error or access violation: 1064 You have an error in your SQL syntax;
check the manual that corresponds to your MariaDB server version for the right
syntax to use near ''0', '10'' at line 1' in C:\xampp\htdocs\plain-
pkr\tutorial_pagination.php:34 Stack trace: #0 C:\xampp\htdocs\plain-
pkr\tutorial_pagination.php(34): PDOStatement->execute(Array) #1 {main} thrown
in C:\xampp\htdocs\plain-pkr\tutorial_pagination.php on line 34
But when i change :parameters to $parameters, it works:
$starting_limit = ($page-1)*$limit;
$show = "SELECT * FROM company ORDER BY id ASC LIMIT $starting_limit, $limit";
$r = $pdo->prepare($show);
$r->execute();
Why's that?