PHP Using PHP with MySQL Limiting Records in SQL Queries Using LIMIT with Offset

limiting records getting data error

I entered this and got data nope 2. WHY?!?!

function get_products_subset($positionStart, $positionEnd) {

    $offset = $positionStart - 1;
    $rows = $positionEnd - $positionStart + 1;

     require(ROOT_PATH . "database.php");

     try {
         $results = $db->prepare("
                  SELECT name, price, img, sku, paypal
                  FORM products
                  ORDER BY sku
                  LIMIT ?, ?");
            $results->bindParam(1,$offset,PDO::PARAM_INT);
            $results->bindParam(2,$rows,PDO::PARAM_INT);
            $results->execute();            
     }catch (Exception $e) {
         echo "data nope 2";
         exit;
     }

     $subset = $results->fetchAll(PDO::FETCH_ASSOC);

     return $subset;
}

2 Answers

Usually I would suggest getting a descriptive error message:

}catch (Exception $e) {
         echo $e->getMessage();
         exit;
     }

However in this case, you might find the problem on this line:

FORM products

LMAO thank you Tim I was freaking out for a long time on this I'm sorry I wasted your time