Fatal error: Uncaught PDOException: 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', '1'' at line 1
There is nothing wrong with my syntax...
$offset = ($current_page__p - 1) * $results_per_page;
$paginator = new Paginator($query->rowcount, $results_per_page, $current_page__p, $webAddr . "admin-panel/accounts/page/(:num)");
$query->prepare("SELECT * FROM accounts LIMIT :startz, :resultsPerPage", array(":startz" => $offset,":resultsPerPage" => $results_per_page), true);
Hello, im trying to make a simple pagination. This is the SQL error that i get, im using PDO connection. There is nothing wrong actually with the syntax. The problem comes after the LIMIT part. If i manually type LIMIT 0,1 for example, no problem it works. But when i use bind parameters it doesn't work. I don't use any negative numbers or using reserved words.
I tried every possible way to fix this, no help from google. All other stackoverflow posts talk about reserved words and simple syntax mistakes. In my case, there is no syntax mistake. Also this is the short SQL class that i wrote.
// Fast query class
class query {
var $result;
var $rowcount;
public function prepare ($tmp_sql,$tmp_parameters,$tmp_get_result){
global $db;
$stmt = $db->prepare($tmp_sql);
$stmt->execute($tmp_parameters)or die(print_r($stmt->errorInfo(), true));
if ($tmp_get_result == true){
$this->result = $stmt->fetchAll();
$this->rowcount = $stmt->rowCount();
}
}
}