fixed syntax error - extra comma at the endof SELECT criteria in $q