Jump to content

PHP/SQL issue. Incorrect Syntax?


FlashNinja

Recommended Posts

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);

Link to comment
https://forums.phpfreaks.com/topic/263893-phpsql-issue-incorrect-syntax/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.