Why am I getting the following error?
Fatal error: Call to undefined method mysqli_stmt::query()
$mysqli = new mysqli("localhost", "***", "***", "***") or die($mysqli->connect_error); function checklogin($username, $password) { global $mysqli; $result = $mysqli->prepare("SELECT * FROM users WHERE username = ?"); $result->bind_param("s", $username); $result->query(); }
Advertisement
Answer
Calling $mysqli->prepare()
will return an instance of MySQLi_STMT
, but the MySQLi_STMT
class doesn’t have a query()
method. Perhaps you meant execute()
?