I have a php script called via an ajax request each time a user presses a button that is supposed to get the next 10 rows of a database. When the button is pressed, nothing happens and I get no errors in the console or from the php
$query = $conn->prepare('SELECT name, file_loc, img_id, filter, votes FROM images WHERE user_id=? ORDER BY votes DESC LIMIT ?, 10');
$query->execute(array($user_id, $skip));
$result = $query->fetchAll();
When I go to phpmyadmin, manually fill in the variables, and run the query directly, it runs properly.
In the php when I add echo $skip . ' ' . $user_id;
to the end of the script, it shows that all the variables are what they are supposed to be. Additionally if I edit the end of the query to use a static number instead of plugging the variable to read LIMIT 10, 10
, then everything works fine (although not being a variable, it can't increment by 10).
I have no idea why this isn't running properly but I feel like I'm overlooking something obvious. Any ideas?