FlashNinja Posted June 9, 2012 Share Posted June 9, 2012 So I have a little problem here. I'm trying to put a limit on an SQL Query, simple. The problem that is arising is that the variables I am using to denote the limit values are causing some funky MySQL syntax error. This is the error: 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','20'' at line 1 Here's the snippet of code that appears to be causing the error. The variables being used for the limit are the values I expect them to be so that doesn't seem to be the issue here. if(isset($_GET['page'])) { $page = $_GET['page']; } else { $page = 1; } $start_from = ($page-1) * 20; $end = $page * 20; $ads = mysql_query("SELECT * FROM ad WHERE usr ='$member' ORDER BY id DESC LIMIT '$start_from','$end'") or die(mysql_error()); $numRowsa = mysql_num_rows($ads); Quote Link to comment https://forums.phpfreaks.com/topic/263893-phpsql-issue-incorrect-syntax/ Share on other sites More sharing options...
Pikachu2000 Posted June 9, 2012 Share Posted June 9, 2012 Remove the single quotes from around the limit variables. Quotes cause the values to be treated as strings. Quote Link to comment https://forums.phpfreaks.com/topic/263893-phpsql-issue-incorrect-syntax/#findComment-1352369 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.