0
try {
    $sql = "SELECT * FROM student LIMIT :offset,:record ";
    $stmt = $conn->prepare($sql);
    $stmt->execute([
        "offset" => 0,
        "record" => 5
    ]);
} catch (PDOException $error) {
    echo  "Error: {$error->getMessage()}";
}

Error: 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','5'' at line 1.

I know that I can do this with query() method but I want to know why this is not working because offset value come using post request so that I want to use prepared statement.

user3783243
  • 5,098
  • 5
  • 16
  • 37

0 Answers0