Here is my function to bring back the most popular videos. For some reason it does not recognize: limit. If I remove the ': limit' and implicitly put it in the number 10, it works.
Method:
function getPopularVideos($limit) {
$dbc = connectToDatabase();
$q = $dbc->prepare('SELECT * FROM video ORDER BY views DESC LIMIT 0, :limit');
$q->execute(array(':limit' => $limit));
return $q->fetchAll(PDO::FETCH_ASSOC);
}
Call Code:
$popularVideos = getPopularVideos(10);
Any idea what I'm doing wrong. A bit confused.
source
share