Title: $wpdb-&gt;get_row not working
Last modified: August 30, 2016

---

# $wpdb->get_row not working

 *  [Toon Gerritsen](https://wordpress.org/support/users/toon-gerritsen/)
 * (@toon-gerritsen)
 * [10 years, 10 months ago](https://wordpress.org/support/topic/wpdb-get_row-not-working/)
 * I try to use the snippet approach to call information from my WP databases, using
   $wpdb. This leads to a fatal error.
    Please find below the sippet coding and 
   the error message.
 * <?php
    $posts = $wpdb->get_row(“SELECT ID, post_title FROM wp_posts WHERE post_status
   = ‘publish’ AND post_type=’post’ ORDER BY comment_count DESC LIMIT 0,1″); // 
   Echo the title of the most commented post echo $posts->post_title; ?>
 * Fatal error: Call to a member function get_row() on null in C:\xampp\apps\wordpress\
   htdocs\wp-content\plugins\php-code-for-posts\PHPPostCode.php(85) : eval()’d code
   on line 6
 * Any advice / suggestion how I can resolve this?
    Regards
 * [https://wordpress.org/plugins/php-code-for-posts/](https://wordpress.org/plugins/php-code-for-posts/)

The topic ‘$wpdb->get_row not working’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/php-code-for-posts_0d1022.svg)
 * [PHP Code for posts](https://wordpress.org/plugins/php-code-for-posts/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/php-code-for-posts/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/php-code-for-posts/)
 * [Active Topics](https://wordpress.org/support/plugin/php-code-for-posts/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/php-code-for-posts/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/php-code-for-posts/reviews/)

## Tags

 * [php](https://wordpress.org/support/topic-tag/php/)
 * [sql](https://wordpress.org/support/topic-tag/sql/)
 * [wpdb](https://wordpress.org/support/topic-tag/wpdb/)

 * 0 replies
 * 1 participant
 * Last reply from: [Toon Gerritsen](https://wordpress.org/support/users/toon-gerritsen/)
 * Last activity: [10 years, 10 months ago](https://wordpress.org/support/topic/wpdb-get_row-not-working/)
 * Status: not resolved