Title: wordpress $wpdb queries
Last modified: August 21, 2016

---

# wordpress $wpdb queries

 *  [rodeored](https://wordpress.org/support/users/rodeored/)
 * (@rodeored)
 * [12 years, 1 month ago](https://wordpress.org/support/topic/wordpress-wpdb-queries/)
 * I have wordpress 3.8.1
    For the most part, the site runs fine, but when I try
   to make my own queries on a table I created, the wpdb object is not working as
   expected. In php admin, I can see table playlists with 4 rows, but the WordPress
   database functions don’t find any rows
 * $sql=”SELECT * FROM wp_playlists”;
    $playlists = $wpdb->get_results($sql);
 * This returns an empty array
    $playlists:0 rows Array ( )
 * Another example:
    $playlists = $wpdb->query( “SELECT * FROM wp_playlists”); $
   playlists:[4];
 * Instead of returning all the fields of all the rows, it simply returns the number
   of rows.
 * What could be causing this problem?

Viewing 3 replies - 1 through 3 (of 3 total)

 *  [vtxyzzy](https://wordpress.org/support/users/vtxyzzy/)
 * (@vtxyzzy)
 * [12 years, 1 month ago](https://wordpress.org/support/topic/wordpress-wpdb-queries/#post-4662683)
 * Is the name of the table actually ‘wp_playlists’? Is that what shows in phpMyAdmin?
 *  Thread Starter [rodeored](https://wordpress.org/support/users/rodeored/)
 * (@rodeored)
 * [12 years, 1 month ago](https://wordpress.org/support/topic/wordpress-wpdb-queries/#post-4662688)
 * Yes, that’s what shows in phpMyAdmin
 *  [vtxyzzy](https://wordpress.org/support/users/vtxyzzy/)
 * (@vtxyzzy)
 * [12 years, 1 month ago](https://wordpress.org/support/topic/wordpress-wpdb-queries/#post-4662698)
 * You may need to declare $wpdb as global:
 *     ```
       global $wpdb;
       $sql="SELECT * FROM wp_playlists";
       $playlists = $wpdb->get_results($sql);
       ```
   

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘wordpress $wpdb queries’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 3 replies
 * 2 participants
 * Last reply from: [vtxyzzy](https://wordpress.org/support/users/vtxyzzy/)
 * Last activity: [12 years, 1 month ago](https://wordpress.org/support/topic/wordpress-wpdb-queries/#post-4662698)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
