Reputation: 37
I'm trying to pass two variables into jQuery's "POST" function, but they don't seem to be getting to my PHP.
<script>
var starting = 0;
var ending = 3;
$(document).ready(function(){
$.post("test.php", {start: starting, end: ending},
function(){});
});
</script>
It's my understanding that I should be able to access "starting" and "ending" by using $_POST["start"] and $_POST["end"], but it doesn't seem to be working. Am I passing these variables incorrectly? Here's the start of my PHP. The script works fine if I hard-code test values for the limit.
$starting = intval($_POST["start"]);
$ending = intval($_POST["end"]);
$query = "SELECT formation_name FROM formations LIMIT '$starting','$ending'";
Upvotes: 0
Views: 71
Reputation: 324620
The MySQL LIMIT
clause takes two integers, not strings. Remove the quotes you have around them.
Upvotes: 7