As you can see I'm trying to fetch rows from table while using prepared statements.
$stmt = $conn->prepare("SELECT * FROM table ORDER BY date DESC LIMIT ?, 10");
$stmt->bindParam(1, $row_start, PDO::PARAM_INT);
$stmt->execute();
while($row = $stmt->fetch()) {
echo $row['title'];
echo $row['name'];
}
It doesn't echo anything.
Edit: var_dump is showing this log :
"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 ''0', 10' at line 1" }
Edit 2: Here is how I declare my $row_start
$row_start = "0";
if (isset($_GET['page']) && is_numeric($_GET['page']) && $_GET['page'] != "0" )
{
$row_start = $_GET['page'];
if ($row_start == "1") {
$row_start = "0";
}else{
$row_start = ($row_start-1) * 10;
}
}
?with a number and run it, it does work.$stmt->bindParam(1, $row_start, PDO::PARAM_INT);var_dump($stmt->errorInfo())print anything?(int) $row_startwith a space.