Which error are you getting? The unexpected '<' error or the original error?
Create a separate php file and do the following:
<?php
# FIRST CONNECT TO THE DATABASE
# THEN
$q = "select codename,id,height,weight,eyes,hair,ethnicity,characteristics,(YEAR(NOW()) - YEAR(dateofbirth)) - (MONTH(NOW()) < RIGHT(dateofbirth,5)) AS age, YEAR(NOW()) as thisYear from cerebra WHERE approved <> '' AND approved IS NOT NULL AND codename IS NOT NULL AND codename <> '' ORDER BY LENGTH(codename) DESC";
$theseChars2 = mysql_query($q,$db) or die(mysql_error());
?>
It is possible that all error reporting are off in the php settings and thats why you are not getting an error when your query is not executing correctly. But php does not have a choice about error reporting when fetcharray function gets an invalid parameter.
Take care of one problem at a time. First make sure that this query executes correctly. And ask your server admin about command line access to mysql. It will make your life easier.