Limit in PDO

I am having problem in using the Limit in PDO,I get sql syntax error.

  $cmd = $this->connection->prepare('SELECT * from user
                                           Limit ?,?


What is your error?

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','10'' at line 1

Just google that error. Check this out

Looks like it might be a String vs. Int thing. does this still error?

Are the variables coming from dirty user supplied values?

Unless told otherwise, PDO sends all params in as strings. You need to bind the params as integers. You can’t do this with execute, you’ll need to use the bindParam method of the statement object.

1 Like

Okay solved it, using bindValue, bindParam doesn’t work.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.