It's quite likely that $galleryid
has an unexpected value, but nevertheless you should use the prepare()
method that Wordpress provides for your queries:
$pictures = $wpdb->get_results(
$wpdb->prepare(
"SELECT * FROM wp_ngg_pictures WHERE galleryid = %d",
$galleryid
)
);
If you want to test the query, you can take the output of prepare()
and run that in phpMyAdmin.