Title: retrieving database data not working
Last modified: August 20, 2016

---

# retrieving database data not working

 *  [surrealillusions](https://wordpress.org/support/users/surrealillusions/)
 * (@surrealillusions)
 * [13 years, 6 months ago](https://wordpress.org/support/topic/retrieving-database-data-not-working/)
 * I have a couple of custom database table rows added to the normal wordpress database,
   however, despite having stuff in the database, nothing is been displayed.
 * After numerous attempts to display the data, I scaled back the code to just this
   to see what was going wrong and why nothing was working right.
 *     ```
       global $wpdb;
       $data = $wpdb->get_results("SELECT * FROM customtable");
       print_r($data);
       ```
   
 * All this produces on the page is
    Array()
 * The code above is placed inside a page template. There are no functions to call
   upon, and no plugins either. No previous database calls other than what WordPress
   already does. It’s as if the data doesn’t exist, which it does.

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

 *  [vtxyzzy](https://wordpress.org/support/users/vtxyzzy/)
 * (@vtxyzzy)
 * [13 years, 6 months ago](https://wordpress.org/support/topic/retrieving-database-data-not-working/#post-3052211)
 * I would suggest trying the identical code in phpMyAdmin to see if it returns 
   any rows.
 *  Thread Starter [surrealillusions](https://wordpress.org/support/users/surrealillusions/)
 * (@surrealillusions)
 * [13 years, 6 months ago](https://wordpress.org/support/topic/retrieving-database-data-not-working/#post-3052218)
 * Turned out to be a mixture of me getting confused with 2 databases and the table
   row names.
 * There was no data because, well..there wasn’t any.
 * Outside of WordPress in PHP, you do something like this:
 * `mysql_select_db("test") or die(mysql_error());`
 * Where the mysql_error tells you of any errors, will that work in WordPress or
   is there something similar to tell you of any errors?
 *  [vtxyzzy](https://wordpress.org/support/users/vtxyzzy/)
 * (@vtxyzzy)
 * [13 years, 6 months ago](https://wordpress.org/support/topic/retrieving-database-data-not-working/#post-3052221)
 * See the Codex article here: [http://codex.wordpress.org/Class_Reference/wpdb#Show_and_Hide_SQL_Errors](http://codex.wordpress.org/Class_Reference/wpdb#Show_and_Hide_SQL_Errors)

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

The topic ‘retrieving database data not working’ 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: [13 years, 6 months ago](https://wordpress.org/support/topic/retrieving-database-data-not-working/#post-3052221)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
