I keep getting the error PHP Fatal error: Call to undefined function mysqli_stmt_get_result(). I am using PHP version 5.6 and have enabled the extension mysqlind in my hosting provider c panel but I can't figure out why I am still getting this error. I have researched and found every time that I need to have mysqli nd enabled to use mysqli_stmt_get_result. Can anyone assist/teach what I am doing wrong. Thank you.
SIGNUP.PHP:
<?php
session_start();
include '../dbh.php';
$respond = array(
'status' => true,
'message' => 'There was an error',
'redirect',
'errors'
);
if (isset($_POST['submit'])) {
$first = $_POST['first'];
$last = $_POST['last'];
$email = $_POST['email'];
$pwd = $_POST['pwd'];
$errorEmpty = false;
$errorEmail = false;
if (empty($first) || empty($last) || empty($email) || empty($pwd)) {
$respond['errors'][] = "Please fill out all fields!";
$respond['errorEmpty'] = true;
} elseif (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
$respond['errors'][] = "Please enter a valid email address!";
$respond['errorEmail'] = true;
} else {
$sql = "SELECT email FROM user WHERE email= ? ";
$stmt = mysqli_prepare($conn, $sql);
mysqli_stmt_bind_param($stmt, 's', $email);
mysqli_stmt_execute($stmt);
$result = mysqli_stmt_get_result($stmt); //This is where I getting my error
$num_rows = mysqli_num_rows($result);
if ($num_rows > 0) {
$respond['errors'][] = "That email address already exists!";
$respond['errorEmail'] = true;
}
else {
$encryptpwd = password_hash($pwd, PASSWORD_DEFAULT);
$sql = "INSERT INTO user (first, last, email, pwd) VALUES (?,?,?,?)";
$stmt = mysqli_prepare($conn, $sql);
mysqli_stmt_bind_param($stmt, 'ssss', $first, $last, $email, $password_hash);
if (mysqli_stmt_execute($stmt)) {
$userID = mysqli_insert_id($conn);
$status = 1;
$sql2 = "INSERT INTO profileImg (email, status) VALUES(?,?)";
$stmt2 = mysqli_prepare($conn, $sql2);
mysqli_stmt_bind_param($stmt2, 'si', $email);
mysqli_stmt_execute($stmt);
$_SESSION['id'] = $userID;
$respond['redirect'] = "../profile.php?id=$userID";
}
}
}
}
echo json_encode($respond);
?>
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…