无法使用PHP mysqli_stmt_fetch从数据库中回显数据

时间:2019-03-03 16:10:33

标签: php

  

我想做的是检查电子邮件和用户名是否已存在于数据库中,然后如果它已存在于数据库中,则我想回显用户名,该如何解决?谢谢

 $sql = "SELECT * FROM user WHERE uidUser=? OR emailUser=?";
    $stmt = mysqli_stmt_init($conn);
        if (!mysqli_stmt_prepare($stmt, $sql)) {
            header("Location: ../signup.php?error=sqlerror");
            exit();
                }
                else {
                    mysqli_stmt_bind_param($stmt, "ss", $username, $email);
                    mysqli_stmt_execute($stmt);
                    mysqli_stmt_store_result($stmt);
                    $resultCheck = mysqli_stmt_num_rows($stmt);



        if ($resultCheck > 0) {
                            while ($row=mysqli_stmt_fetch($stmt)) {
                                echo "Name: ".$row['uidUser'];
                            }                   
                        }

    }

0 个答案:

没有答案