php - How to apply bindValue method in LIMIT clause? -
Here is a snapshot of my code:
$ fetchPictures = $ PDO-> ; Prepare ("Choose From Photos * Album Where: ALCID Order By ADC Limit: Skip, Max:"); $ False Image- & gt; Bind Value (': Album Id', $ _GET ['Album'], PDO :: Paramax); If (isset ($ _GET ['skip'])) {$ fetchPictures-> BindValue (': skip', trim ($ _GET ['skip']), PDO: Paramatti); } And {$ fetchPictures-> Byte value (': Skip', 0, PDO :: Paramatti); } $ Fetch Image-> Bind value (': max', $ max, pdo: parametti); Fetch $-> Ficture-> Execute () or die (print_r ($ fetch-pictures-> ErrorInfo ())); $ Picture = $ Fetch - Image-> Fetch All (PDO :: FETCH_ASSOC);
I get
There is an error in your SQL syntax; It seems that the PDO is adding single quote to my variable, which is manual for the right syntax to use near "15", "Line 1", which matches your MySQL server version is. I saw a limited portion of the SQL code, I found this bug that I think is related:
Am I watching? This bug has been opened since April 2008! What should we do in the meantime?
I need to make some page-digits, and it is necessary to ensure that data is clean, SQL injection-safe before sending SQL statement.
I remember this problem before casting a value in an integer before passing it to the function. . I think it solves it.
$ fetchPictures-> gt; BindValue (': skip', (int) trim ($ _GET ['skip']), PDO :: PARAM_INT;
Comments
Post a Comment