Page 1 of 1

Problem with ORDER BY col_name LIMIT 0,15

Posted: Sun Dec 15, 2002 12:39 am
by phice
So I've been working on this database, blah blah.

$start_pos = 0, $num_links = 15, $order_by = "added"

My SQL:

Code: Select all

SELECT * FROM `aref_users` LIMIT $start_pos,$num_links ORDER BY $order_by
"added" is a column name.

Error: "You have an error in your SQL syntax near ' ORDER BY ' at line 1"

When I switch the "LIMIT $start_pos,$num_links" and the "ORDER BY $order_by", I get the error: "You have an error in your SQL syntax near 'LIMIT ,' at line 1"

Any help?

Posted: Sun Dec 15, 2002 12:42 am
by nieve
try this
SELECT * FROM `aref_users` ORDER BY $order_by LIMIT $start_pos,$num_links

Posted: Sun Dec 15, 2002 3:42 am
by phice
bah. I had all of the tags set inside a while(), and i didn't have that query inside. Weird.