The MU forums have moved to WordPress.org

Codex question (2 posts)

  1. ninnypants
    Member
    Posted 15 years ago #

    I'm trying to use the $wpdb->get_var() function, and am getting this error
    Fatal error: Call to a member function get_var() on a non-object in /home/ninnypan/public_html/beta/form_logic.php on line 10

    I've use the function on regular WP and have never had any problems. Any Ideas on what my problem could be?
    My code is:
    $usr = $wpdb->get_var("SELECT count(*) FROM $wpdb->users WHERE user_login = '$username'");

  2. cafespain
    Member
    Posted 15 years ago #

    You've got the

    global $wpdb;

    at the top of that function definition, yes? And you're loading WordPress at the top of your php file, I say that because I note that the path of your form_logic.php file doesn't appear to be in the plugins or mu-plugins directories.

About this Topic

  • Started 15 years ago by ninnypants
  • Latest reply from cafespain