PHP: Warning: sort() expects parameter 1 to be array, resource given

The warning is pretty clear: mysql_query does not return an array with results from the query, but a resource. You need a function like mysql_fetch_array() to return the data you need (and on which you can perform a sort operation).

See the manual for the use of mysql_query() http://nl3.php.net/mysql_query

And maybe unrelated, but you can sort your results in MySQL right away by adding ORDER BY <fieldname> to your query.

Leave a Comment