Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.
Moderator: General Moderators
anon404
Forum Newbie
Posts: 12 Joined: Wed Dec 23, 2009 4:09 am
Post
by anon404 » Fri Dec 25, 2009 11:02 pm
Code: Select all
$result = mysql_query("SELECT filename, ext FROM files ORDER BY '$sort'") or die(mysql_error());
The query results are not sorted. When using a static 'filename' instead of the $sort variable it sorts the result. I have tried all suggested usages for people who have had the same problem with no success. How can i fix this?
alex.barylski
DevNet Evangelist
Posts: 6267 Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg
Post
by alex.barylski » Sat Dec 26, 2009 1:07 am
Try:
Code: Select all
$result = mysql_query("SELECT filename, ext FROM files ORDER BY $sort") or die(mysql_error());
I don't think those single quotes aorund $sort are required or desired.
Cheers,
Alex
anon404
Forum Newbie
Posts: 12 Joined: Wed Dec 23, 2009 4:09 am
Post
by anon404 » Sat Dec 26, 2009 8:14 am
PCSpectra wrote: Try:
Code: Select all
$result = mysql_query("SELECT filename, ext FROM files ORDER BY $sort") or die(mysql_error());
I don't think those single quotes aorund $sort are required or desired.
Cheers,
Alex
Syntax error.
Edit: Solved, $sort was null... lol