Ugleh Ugleh - 4 months ago 50
MySQL Question

PHP Order By not working

Here is my PHP Query, but it doesn't seem to order the results. Everything else works fine.

FROM `main`
WHERE `user_legacy` LIKE '%".$name."%'
ORDER BY 'user_legacy' DESC LIMIT ".$limit


You use backticks (') to quote column names in SQL, not the normal single quote (').

ORDER BY `user_legacy` DESC

Also, if you don't do any kind of vetting or your input, that query is potentially vulnerable to an SQL injection.