1

I'm getting this fatal error for using limit in my loop, but if I don't use it I won't be able to break down my content into separate pages. How can I perform the pagination without getting a fatal error every time someone visits the site?

$start = $_GET['start']; 
$per_page = 60;

//count recoreds
$data = $db->query("SELECT * FROM artists");
$record_count= $data->rowCount();

//count max pages
$max_pages = $record_count / $per_page;

//may come out as a decimal
if (!$start)
    $start = 0; 

$sth = $db->prepare("SELECT * FROM artists ORDER BY name LIMIT ?,?");
$sth->execute(array($start,$per_page));

foreach($sth as $info) { //return content }
  • 1
    try `$sth->bindParam([1, $start]); $sth->bindParam(2, $per_page); $sth->execute();` – Naumov Oct 02 '18 at 19:01
  • the first one didn't need the '[ ]' but after removing that it worked! I'm not getting errors anymore but sometimes my error logger takes a bit of time to catch them but for now it looks good. thanks so much! – Mark Serrano Oct 02 '18 at 19:19
  • 1
    sorry I simple edit comment and forgot remove `[]` – Naumov Oct 02 '18 at 19:21

0 Answers0