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

or

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:

http://www.php-mysql-tutorial.com/php-mysql-paging.php

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

Member Avatar for Rhyan

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...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.