-1

I don't know why but i have a syntax error, my code looks completely fine to me,

$page = $_POST['page'];
$amount = $_POST['amount'];



$Realpage = intval($page);
$Realamount = intval($amount);
$query = $con->prepare(
   "SELECT 
      * 
    FROM 
      store 
    AS 
      s
    INNER JOIN 
      product_pictures AS pp 
    ON 
      s.product_id = pp.id 
    INNER JOIN 
      product_name AS pn 
    ON 
      s.product_id = pn.id 
    WHERE 
      (s.product_price BETWEEN :firstPrice AND :secondPrice) AND 
      product_name LIKE :input LIMIT :page , :amount ");

$query->execute(array(':input' => "%" . $input . "%" , ":firstPrice" => intval($firstPrice), ":secondPrice" => intval($secondPrice) , ':page' => $Realpage * $Realamount, ':amount' => $Realamount));

Error:

Fatal error: Uncaught exception 'PDOException' with message '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 ''0' , '20'' at line 1'

dognose
  • 20,360
  • 9
  • 61
  • 107
Guy Sudai
  • 36
  • 5

1 Answers1

1

LIMIT and PAGE in your SQL cannot be part of statement preparation.

sbrbot
  • 6,169
  • 6
  • 43
  • 74