0

致命的なエラー:47行目の/home/dbc/public_html/CEHPLearning/wp-content/themes/cehpLearning/page-password-reset.phpにある非オブジェクトのメンバー関数query()を呼び出す

    <div class="content-page">

    <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>

        <div class="the-post-container">

            <?php if (!get_meta('hide_title')) : ?>
            <header class="entry-header">
                <!-- Title / Page Headline -->
                <h1 class="entry-title" title="<?php echo the_title_attribute('echo=0'); ?>"><?php the_title(); ?></h1>
            </header>
            <?php endif; ?>

            <!-- Page Text and Main Content -->
            <div class="entry-content clearfix">

                <?php
                $error = '';
                $success = '';
                $user_id = get_current_user_id();

                if(isset($_POST['task']) && $_POST['task'] == 'reset') {

                $password = $_POST['pwd1'];
                $con_password = $_POST['pwd2'];

                if($password == "" || $con_password == "") { 
                $error = 'Password field is required.'; 
                } else if($password <> $con_password){
                $error = 'Password does not match.';
                } else {
                    $qry = $wpdb->query("UPDATE $wpdb->users SET user_pass = '".md5($password)."' WHERE ID=$user_id "); 
                    if($qry) { 
                        $success= 'Password updated successfully, it will take effect in your next login.'; 
                    }
                }
                }
                ?>
                <?php the_content(); ?>
                <div class="pwChangeBox">
                    <form name="frmreset" id="frmreset" action="" method="post">
                        <h3>Don't like your password?<br/>
                        <span>Try a new one.</span></h3><br/>
                        <div class="msgBox"> <?php if($error != "") : echo '<p class="errormsg">'.$error.'</p>'; endif; if($success != "") : echo '<p class="successmsg">'.$success.'</p>'; endif; ?> </div>
                        <label>Password</label><br/>
                        <input type="password" value="<?php echo (isset($_POST['pwd1']) ? $_POST['pwd1'] : ''); ?>" name="pwd1" id="pwd2" /><br/> 
                        <br/>   
                        <label>Password Again</label><br/>
                        <input type="password" value="<?php echo (isset($_POST['pwd2']) ? $_POST['pwd2'] : ''); ?>"" name="pwd2" id="pwd2" /><br/>
                        <br/>
                        <button type="submit" class="alignleft" >SUBMIT</button>
                        <input type="hidden" name="task" value="reset" />
                    </form>
                </div>

            </div>

    </article>

</div>

問題の行は...です。

$qry = $wpdb->query("UPDATE $wpdb->users SET user_pass = '".md5($password)."' WHERE ID=$user_id "); 

誰か助けてもらえますか?

4

1 に答える 1

3

最初にグローバル$wpdbインスタンスを呼び出す必要があります。したがって、クエリを実行する前に、次を追加します。

global $wpdb;
于 2012-12-29T02:30:03.227 に答える