$sql = "SELECT sql_calc_found_rows * FROM members".
" ORDER BY username LIMIT :startRow, :numRows";
try {
$st = $conn->prepare($sql);
$st->bindParam(":startRow", $startRow, PDO::PARAM_INT);
$st->bindParam(":numRows", $numRows, PDO::PARAM_INT);
$st->execute();
} catch (PDOException $e) {
die("Query failed: " . $e->getMessage());
}
Qui ottengo l'errore:errore PHP DOP quando si utilizza segnaposti nella clausola LIMIT di una query MySQL
Query failed: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''5'' at line 1.
Il LIMIT :startRow, :numRows
ha problema a :numRows
.
Ho provato sia $st->bindParam
e $st->bindValue
, entrambi non hanno funzionato.
Puoi provare a rimuovere ° vuota tra ': startRow,: numRows' – Jens
valore di $ ordine? –
SELECT sql_calc_found_rows * FROM ?? cos'è questo? –