I'm interested in the limit parameter. When ever I try to use that I get this 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,5)' at line 5"

this is the line in question:

ORDER BY table.smth ASC LIMIT (0,5)";

It's part of a query that works perfectly if I remove the limit parameter so the errore can only be here.

In some examples I have seen it used like :

ORDER BY table.smth ASC LIMIT 0,5";


ORDER BY table.smth ASC LIMIT 5";

But all will output the same error for me... I need the limit in order to split my query results in multyple pages... I'm folowing this tutorial BTW:


But the limit parameter just won't work for me... can anybody help please?

8 Years
Discussion Span
Last Post by marcmm

Hmm...really strange. Normally LIMIT does not require brackets around the parameters, so LIMIT 0,5 should work for you.
I suggest you to run your sql query in an mysql graphical tool first and then see what results it will return for you.
So, instead of doing mysql_query($querry_string), use echo $query_string, copy the output from your page and execute the query in GUI tool. Then you will see where the error may be. Once you know what causes the error, you just need to correctly format your querry in PHP and execute it from the page.


Ok this is weird... I tryed executing the string again today and it worked... but it wouldn't work yesturday... I don't get it...

the string dose not work with paranteses that I figured out... but I'm positive I tryed without paranteses yesturday and it did not work... and it works today... I am at a loss as to what happened... but reguardless... it was like this:

limit 0,5

I guess problem solved...

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.