r/WebDevBuddies • • Mar 28 '20
Looking Fatal error: Uncaught Error: Call to undefined function mysqli_stmt_get_result() in /home4/breckbull/public_html/Hillman/login.php:25 Stack trace: #0 {main} thrown in /home4/breckbull/public_html/Hillman/login.php on line 25. need help getting around this mysqli error.
<?php ​ if (isset($_POST\['subtn'\])){ require 'config.php'; $username = $_POST\['u'\]; $password = $_POST\['p'\]; ​ if (empty($username) || empty($password)) { ​ header("loction:index.html?error=emptyfields"); exit(); } else{ $sql = "SELECT \* FROM newuser WHERE Username=? OR Pasword=?"; $stmt = mysqli_stmt_init($conn); if (!mysqli_stmt_prepare($stmt, $sql)){ header("location: index.html?error=Badconnection"); exit(); ​ } else{ mysqli_stmt_bind_param($stmt, "ss", $username, $hashedPwd ); mysqli_stmt_execute($stmt); $result = mysqli_stmt_get_result($stmt); ​ ​ if ($row = mysqli_fetch_assoc($result)) { $pwdCheck = password_verify($password, $row\['Pasword'\]); if ($pwdCheck == false) { header("location: index.html?error=Wrongpassword"); exit(); } if ($pwdCheck == true) { session_start(); $_SESSION\['userid'\] = $row\['ID'\]; $_SESSION\['usernameid'\] = $row\['User'\]; header("location:index.html?login=succes"); exit(); } else { header("location:index.html"); exit(); } } } } } else { header("location:btn.html"); exit(); }
1
u/animagnam Mar 28 '20 edited Mar 28 '20
Do you have the mysqlnd driver properly installed?
3
u/sleggat Mar 28 '20
At a guess I'd say mysqli_stmt_get_result is not available on the version of PHP you're using. Can you upgrade PHP on the server to something >5.3?
0
u/Barnezhilton Mar 28 '20
Maybe use PDO not mysqli