• I am a newbe and I am trying to create a php file all on my own, and I would like to do a simple test to see that I have connected to my database correctly. And here is the code I am using to do the test…

    <?php
    global $wpdb;

    $query = $wpdb->get_results(“Select post_title, ID, post_content, post_date, comment_count, iphone_image FROM wp_posts”);

    blah-blah-blah…….
    echo….blah-blah-blah.
    ?>

    I get an error :
    Fatal error: Call to a member function get_results() on a non-object in /home/mysite/public_html/wp-includes/stuff/remote/tester.php on line 4

    I have done everything I can find in this forum, and I probably don’t have it globalized properly…can someone tell me what to do?

    Thanks

Viewing 2 replies - 1 through 2 (of 2 total)
  • Try using the $wpdb syntax for tablenames, like this

    $fivesdrafts = $wpdb->get_results("SELECT ID, post_title FROM $wpdb->posts
    	WHERE post_status = 'draft' AND post_author = 5");

    Thread Starter ronbowalker

    (@ronbowalker)

    I did that just as you said….but no success.

    I appreciate the suggestion anyway. Thanks.

    Any other ideas are welcomed.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘global $wpdb’ is closed to new replies.