ERROR: Could not execute query!

PROC:: get_pictures_by_species

'website_class.php' :: select_pictures_by_species()

ERROR: 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 ') AND pictures.published = 'Y' GROUP BY pictures.artist_id, p

array (
  'name' => 'select_pictures_by_species',
  'params_in' => 
  array (
    0 => '@id',
  ),
  'params_out' => 
  array (
  ),
  'body' => 'SELECT 
  pictures.id,
	pictures.artist_id,
  pictures.title pic_title,
	pictures.alt_tag,
	pictures.thumb_imgs1,
  artists.title,
  artists.firstname,
  artists.surname,
  artists.letters,
	species.name
FROM
  pictures
  INNER JOIN picture_species_joining ON (pictures.id = picture_species_joining.picture_id)
  INNER JOIN artists ON (artists.id = pictures.artist_id)
	INNER JOIN species ON (picture_species_joining.species_id = species.id)
WHERE
  (picture_species_joining.species_id = @id) 
AND
  pictures.published = \'Y\'
GROUP BY pictures.artist_id, pictures.id
ORDER BY artists.surname
',
  'values' => 
  array (
    0 => NULL,
  ),
)