mysqli free results

Codes here !

Moderators: egami, macek, gesf

Post Reply
New php-forum User
New php-forum User
Posts: 14
Joined: Sat May 28, 2011 5:12 pm

Sat Feb 22, 2014 2:38 pm


I am new to all of this, so please be patient. I am trying to convert over to mysqli and searched the net for samples and now I am stuck on trying to free the binding results. Every example I saw always had 1 field in the binding results and later it was freed, but I have a query with a few fields and some how can't figure out how to clear the memory. Can anyone help me please.

Code: Select all



// Check for errors
   echo mysqli_connect_error();

// Create a prepared statement
if($stmt = $mysqli -> prepare ("SELECT id, username, password FROM users WHERE password=?"))
// Bind parameters s - String, b - Boolean, i - Integer etc

$stmt -> bind_param("s", $password);

// Execute it
$stmt -> execute();

// Bind result variables
$stmt->bind_result($id,$username,$password);  // HERE

// Fetch the result of the query
   echo $id . ' - ' . $password . ' - ' . $username;
   echo "<br />";

// Free the memory of the results
mysqli_free_result($result);  //HERE

// Close statement
 $stmt -> close();

// Close connection
$mysqli -> close();

Post Reply