SELECT `id` FROM `users` WHERE `gender` LIKE '$gender'
AND `status` LIKE '$status' AND `age` > $age_from AND `age` < $age_to AND `has_pic` = 'Y'
LIMIT $limitvalue, $limit
mysql_error() tells me this: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 3. Not too informative . Plase help...
(Possbile values variables include %, as well as values, hence the LIKE instead of =).