Keith Drake Waggoner
Keith Drake Waggoner

Reputation: 783

Call to undefined function mysqli_bind_result

When executing the

mysqli_bind_result();

I receive an error saying "Call to undefined function".

My code looks as follows:

$mysqli = new mysqli("localhost", "root", "", "*****");
if(isset($_POST['login'])){
    if($_POST['username']){
    if($_POST['password']){
    $username = $_POST['username'];
    $passwordtmp = $_POST['password'];
    $password = md5(md5($passwordtmp));
    //Connect to Database//
    if ($mysqli->connect_errno) {
            echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
    }
    //Check if user exist in database//
    $query = mysqli_query($mysqli,"SELECT * FROM users WHERE username = '$username'");
    $numrows = mysqli_num_rows($query);
    if($numrows == 1){
        if($stmt = mysqli_prepare($mysqli, "SELECT password FROM users WHERE username = '$username'")){
            mysqli_execute($stmt);
                    mysqli_bind_result($stmt,$passw);
                    while(mysqli_stmt_fetch($stmt)){
                        $pass = $passw;  
                    }

Additional Information:

  1. I transfered this code from a different computer to my laptop using the same connection to my mysql database.

       $mysqli = new mysqli("localhost", "root", "", "*****");
    
  2. I copied the exact database to my laptop and both my computer and laptop are using wamp.

  3. I am wondering if this could be a connection to the database issue, or just a coding error. But it works perfectly on my original computer without any problems.

Upvotes: 1

Views: 956

Answers (1)

nickb
nickb

Reputation: 59699

You're probably using PHP > 5.4, as the function mysqli_bind_result was removed in PHP 5.4.

Change it to mysqli_stmt_bind_result and that should fix your problem.

mysqli_stmt_bind_result($stmt, $passw);

Upvotes: 5

Related Questions