title: Fatal error: Call to a member function query() on a non-object (wordpress 3..5)
body: <p>Fatal error: Call to a member function query() on a non-object in /home/dbc/public_html/CEHPLearning/wp-content/themes/cehpLearning/page-password-reset.php on line 47</p>
  
  <pre><code>    &lt;div class="content-page"&gt;
  
      &lt;article id="post-&lt;?php the_ID(); ?&gt;" &lt;?php post_class(); ?&gt;&gt;
  
          &lt;div class="the-post-container"&gt;
  
              &lt;?php if (!get_meta('hide_title')) : ?&gt;
              &lt;header class="entry-header"&gt;
                  &lt;!-- Title / Page Headline --&gt;
                  &lt;h1 class="entry-title" title="&lt;?php echo the_title_attribute('echo=0'); ?&gt;"&gt;&lt;?php the_title(); ?&gt;&lt;/h1&gt;
              &lt;/header&gt;
              &lt;?php endif; ?&gt;
  
              &lt;!-- Page Text and Main Content --&gt;
              &lt;div class="entry-content clearfix"&gt;
  
                  &lt;?php
                  $error = '';
                  $success = '';
                  $user_id = get_current_user_id();
  
                  if(isset($_POST['task']) &amp;&amp; $_POST['task'] == 'reset') {
  
                  $password = $_POST['pwd1'];
                  $con_password = $_POST['pwd2'];
  
                  if($password == "" || $con_password == "") { 
                  $error = 'Password field is required.'; 
                  } else if($password &lt;&gt; $con_password){
                  $error = 'Password does not match.';
                  } else {
                      $qry = $wpdb-&gt;query("UPDATE $wpdb-&gt;users SET user_pass = '".md5($password)."' WHERE ID=$user_id "); 
                      if($qry) { 
                          $success= 'Password updated successfully, it will take effect in your next login.'; 
                      }
                  }
                  }
                  ?&gt;
                  &lt;?php the_content(); ?&gt;
                  &lt;div class="pwChangeBox"&gt;
                      &lt;form name="frmreset" id="frmreset" action="" method="post"&gt;
                          &lt;h3&gt;Don't like your password?&lt;br/&gt;
                          &lt;span&gt;Try a new one.&lt;/span&gt;&lt;/h3&gt;&lt;br/&gt;
                          &lt;div class="msgBox"&gt; &lt;?php if($error != "") : echo '&lt;p class="errormsg"&gt;'.$error.'&lt;/p&gt;'; endif; if($success != "") : echo '&lt;p class="successmsg"&gt;'.$success.'&lt;/p&gt;'; endif; ?&gt; &lt;/div&gt;
                          &lt;label&gt;Password&lt;/label&gt;&lt;br/&gt;
                          &lt;input type="password" value="&lt;?php echo (isset($_POST['pwd1']) ? $_POST['pwd1'] : ''); ?&gt;" name="pwd1" id="pwd2" /&gt;&lt;br/&gt; 
                          &lt;br/&gt;   
                          &lt;label&gt;Password Again&lt;/label&gt;&lt;br/&gt;
                          &lt;input type="password" value="&lt;?php echo (isset($_POST['pwd2']) ? $_POST['pwd2'] : ''); ?&gt;"" name="pwd2" id="pwd2" /&gt;&lt;br/&gt;
                          &lt;br/&gt;
                          &lt;button type="submit" class="alignleft" &gt;SUBMIT&lt;/button&gt;
                          &lt;input type="hidden" name="task" value="reset" /&gt;
                      &lt;/form&gt;
                  &lt;/div&gt;
  
              &lt;/div&gt;
  
      &lt;/article&gt;
  
  &lt;/div&gt;
  </code></pre>
  
  <p>The line in question is....</p>
  
  <pre><code>$qry = $wpdb-&gt;query("UPDATE $wpdb-&gt;users SET user_pass = '".md5($password)."' WHERE ID=$user_id "); 
  </code></pre>
  
  <p>Can anyone help out??</p>