Title: [WordPress database error] [Nextgen Gallery]
Last modified: August 20, 2016

---

# [WordPress database error] [Nextgen Gallery]

 *  [4nt0n](https://wordpress.org/support/users/4nt0n/)
 * (@4nt0n)
 * [14 years, 6 months ago](https://wordpress.org/support/topic/wordpress-database-error-nextgen-gallery/)
 * I have created the following function
 *     ```
       function nggfirstImage()
       	{
       	   global $wpdb;
       	   $firstImage = $wpdb->get_var("SELECT pid FROM $wpdb->wp_ngg_pictures WHERE galleryid=1 AND sortorder=1");
       	   	echo $firstImage;
       ```
   
 *  }
 * But I get the following 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 ‘WHERE galleryid=1 AND 
   sortorder=1’ at line 1]
    SELECT pid FROM WHERE galleryid=’1′ AND sortorder=’1′
 * Any ideas??
 * cheers
    4nt0n

The topic ‘[WordPress database error] [Nextgen Gallery]’ is closed to new replies.

## Tags

 * [query](https://wordpress.org/support/topic-tag/query/)

 * 0 replies
 * 1 participant
 * Last reply from: [4nt0n](https://wordpress.org/support/users/4nt0n/)
 * Last activity: [14 years, 6 months ago](https://wordpress.org/support/topic/wordpress-database-error-nextgen-gallery/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
