SQL SELECT查询没有结果,也没有错误

时间:2016-12-30 05:15:50

标签: php mysql

我正在编程的网站需要一个简单的登录页面,并且在所述登录页面中,我正在尝试编程,以便在用户尝试使用现有用户名和/或电子邮件登录时发生错误。无论我输入的SELECT查询都没有绑定,我没有得到任何错误,所以我很困惑。我可以使用相同的MySQL连接和相同的列标签插入数据库,所以我确定没有拼写错误。我很感激任何帮助,我仍然是学生,所以请原谅我任何我看不到的明显问题。 我还应该提一下,我回应了每一篇文章并正确分配了

$name=$_POST['name'];
    $pName=$_POST['username'];
    $email=$_POST['email'];
    $s='asdfasdf';
    $formPosted = 2;


if(strlen($_POST['email']) > 2){
        $stmt = $mysqli->prepare("SELECT user_id FROM tbl_users WHERE user_email = ?");
        $stmt->bind_param('s', $email);
        $stmt->execute();
        $stmt->bind_result($eid);
        $stmt->close();
        echo $email.'= '.$eid.'<br>';
        if(isset($eid)){
            $email_error = '<div class="alert alert-danger">
                                    Sorry this email is taken.
                                  </div>';
                                  $row = 0;
                                  $error = 1;
    }}
    else{

    }

回声用于解决问题

if($error==0){
        $stmt = $mysqli->prepare('INSERT INTO tbl_users (user_email, user_name, user_penName, user_pw) VALUES (?,?,?,?) ');
        $stmt->bind_param('ssss', $email, $name, $pName, $pw);
        if($stmt->execute()){

        }

        $stmt->close();
        $mysqli->close();
        //header('Location: index.php');
        //exit();
    }

    $mysqli->close();

这是我在相同连接下的insert语句。 $ error的工作取决于Isset问题,但我测试了它,我知道它有效。

1 个答案:

答案 0 :(得分:1)

改变
/*
 * Set Selectbox for Custom taxonomy "courses" in admin panel
 */

function custom_meta_box() {
    remove_meta_box('tagsdiv-courses', 'help_lessions', 'side');
    add_meta_box('tagsdiv-courses', 'Course', 'Courses_meta_box', 'help_lessions', 'side');
}
add_action('add_meta_boxes', 'custom_meta_box');

/* Prints the taxonomy box content */

function courses_meta_box($post) {

    $tax_name = 'courses';
    $taxonomy = get_taxonomy($tax_name);
?>
    <div class="tagsdiv" id="<?php echo $tax_name; ?>">
        <div class="jaxtag">
    <?php
    // Use nonce for verification
    wp_nonce_field(plugin_basename(__FILE__), 'courses_noncename');
    $help_ids = wp_get_object_terms($post->ID, 'courses', array('fields' => 'ids'));
    wp_dropdown_categories('taxonomy=courses&hide_empty=0&orderby=name&name=courses&show_option_none=Select Course&selected=' . $help_ids[0]);
    ?>
        <p class="howto">Select your Course</p>
        </div>
    </div>
    <?php
}

/* When the post is saved, saves our custom taxonomy */

function courses_save_postdata($post_id) {
    // verify if this is an auto save routine. 
    // If it is our form has not been submitted, so we dont want to do anything
    if (( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE ) || wp_is_post_revision($post_id))
        return;

    // verify this came from the our screen and with proper authorization,
    // because save_post can be triggered at other times

    if (!wp_verify_nonce($_POST['courses_noncename'], plugin_basename(__FILE__)))
        return;

    // Check permissions
    if ('help_lessions' == $_POST['post_type']) {
        if (!current_user_can('edit_page', $post_id))
            return;
    }
    else {
        if (!current_user_can('edit_post', $post_id))
            return;
    }

    // Now, we need to find and save the data

    $help_id = $_POST['courses'];
    $help = ( $help_id > 0 ) ? get_term($help_id, 'courses')->slug : NULL;
    wp_set_object_terms($post_id, $help, 'courses');
}
add_action('save_post', 'courses_save_postdata');

$stmt = $mysqli->prepare("SELECT user_id FROM tbl_users WHERE user_email = ?");
        $stmt->bind_param('s', $email);
        $stmt->execute();
        $stmt->bind_result($eid);
        $stmt->close();
        echo $email.'= '.$eid.'<br>';
        if(isset($eid)){