I've been working on a forum, and now that's it almost done I'm cleaning up my code.
I changed this (which works perfectly):
$replyquery = $engine->runQuery("SELECT * FROM forum_posts WHERE topic_id=:topic_id AND deleted='0' ORDER BY timestamp ASC LIMIT $fromRecordNum, $recordsPerPage");
$replyquery->execute(array(':topic_id'=>$thread['id']));
To this:
$replyquery = $engine->runQuery("SELECT * FROM forum_posts WHERE topic_id=:topic_id AND deleted='0' ORDER BY timestamp ASC LIMIT :recordsNum, :recordsPerPage");
$replyquery->execute(array(':topic_id'=>$thread['id'],':recordsNum'=>$fromRecordNum,':recordsPerPage'=>$recordsPerPage));
It seems the second one does not work and throws me an error:
PHP 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 MariaDB server version for the right syntax to use near ''0', '10'' at line 1'
Which is weird, because they should technically be both the same, right? Can anyone tell me what is going wrong and how I should resolve this?