Forums

[resolved] Can't Print $wpdb->queries (5 posts)

  1. shoffy
    Member
    Posted 1 month ago #

    I'm following the instructions about how to use the define('SAVEQUERIES', true) found at: http://codex.wordpress.org/Editing_wp-config.php

    The issue is, when I add the footer code:

    <?php
    if (current_user_can('level_10')){
        global $wpdb;
        echo "<pre>";
        print_r($wpdb->queries);
        echo "</pre>";
    }
    ?>

    and refresh the page (in the hopes of seeing the various queries), I get a partially rendered page (stops rendering after wp_head hook finishes).

    Unfortunately, there are no error messages being returned (even with WP debug active) so I'm at a loss for troubleshooting.

    Thoughts?

  2. apljdi
    Member
    Posted 1 month ago #

    Start commenting the code until you get a full page load. That is, comment out everything inside of the curly braces. Load the page. If it fails you know that it is failing at if (current_user_can('level_10')). Also, make sure you haven't added an opening php block-- <?php-- inside another opening block.

  3. shoffy
    Member
    Posted 1 month ago #

    @apljdi thank you!

    Did comment out various areas and found that the print_r($wpdb->queries) is where things break. It's just difficult to know why w/o any PHP errors.

    Additional thoughts?

  4. apljdi
    Member
    Posted 1 month ago #

    Use var_dump instead and try just var_dump($wpdb); and see what happens. That said, the Codex code works perfectly for me. All I can think of is that you are running into some server configuration issues.

  5. shoffy
    Member
    Posted 4 weeks ago #

    @apljdi thanks!

    I did try that to no avail. So strange.

    I've abandoned my pursuit as I found a plugin that doesn't seem to have this problem associated with it.

    Thanks again for you help!

Reply

You must log in to post.

About this Topic