0

On my regular computer this works fine, but on my host, which is hostgator, I keep getting this fatal error. it's saying the undefined function mysqli_stmt_get_result()

fatal error: Uncaught Error: Call to undefined function mysqli_stmt_get_result() in /home2/joe773/myblogs.live/loginSocialMediaPosts/includes/login.php:17 Stack trace: #0 {main} thrown in /home2/joe773/myblogs.live/loginSocialMediaPosts/includes/login.php on line 17

if(isset($_POST['login-submit'])) {
   require "../config/db.php";
    $unameEmail = $_POST['unameEmail'];
    $password = $_POST['pwd'];

    $sql = "SELECT * FROM users WHERE username=? OR email=?; "; 
    $stmt = mysqli_stmt_init($conn);
    if(!mysqli_stmt_prepare($stmt, $sql)) {
    header("Location: ../index.php?error=sqlerror");
    }else{
        mysqli_stmt_bind_param($stmt, "ss", $unameEmail, $unameEmail);
    mysqli_stmt_execute($stmt); 
        $result = mysqli_stmt_get_result($stmt);
        if($row = mysqli_fetch_assoc($result)) {
        $pwdCheck = password_verify($password, $row['password']);
        if($pwdCheck == false) {
            header("Location: ../index.php?error=wrongPassword");
            exit(); 
            }elseif($pwdCheck == true) {
                session_start();
                $_SESSION['userId'] = $row['id'];
                $_SESSION['username'] = $row['username'];
                header("Location: ../index.php?login=success");
            }


    }else{
        header('Location: ../index.php?error=wrongPassword');
    }
}

}

Joe Powell
  • 23
  • 5
  • The hosting service doesn't have the MYSQLND driver. – Barmar May 19 '20 at 22:01
  • Side note: Don't start the session so far below like that. If anything should fail before that, it'll most likely make it output before header. You should add `exit;` after each header also – Funk Forty Niner May 19 '20 at 22:04
  • Thanks guys. I am using hostgator. So you think it might be because it dont have mysqli ? Hmm I got it working now but I am using PDO but also put the session on top like you said – Joe Powell May 20 '20 at 23:08

0 Answers0