What is wrong with this query?
I can’t get this query to pass these arguments!
$offset = 5;
$rowsperpage = 10;
$stmt = $db->prepare("SELECT * FROM table ORDER BY ID DESC LIMIT ?,?");
if ($stmt->execute(array($offset, $rowsperpage))) {
while ($row = $stmt->fetch()) {
echo $row['title'];
}
}
If I change the query to this it works fine, but I need to pass the strings because they are dynamic.
$stmt = $db->prepare("SELECT * FROM table ORDER BY ID DESC LIMIT 5,10");
if ($stmt->execute(array($offset, $rowsperpage))) {
while ($row = $stmt->fetch()) {
echo $row['title'];
}
}
I have a feeling that “lazy execution” treats all parameters as strings and thus enclose them in quotes.
So, either bind your parameters explicitly, using bind_param instead of passing array into execute()
or set emulation mode to off
right after connect.
anyway, you have to get in touch with the error message first.
So, setting this one
will reveal the error message to you