mysqli free results

Codes here !

Moderators: macek, egami, gesf

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

mysqli free results

Postby pepelepew1962 » Sat Feb 22, 2014 2:38 pm

Hello:

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

<?php

require("dbcon.php");

// Check for errors
if(mysqli_connect_errno())
{
   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
$password='123';

$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
while($stmt->fetch())
{
   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();
?>

Return to “mySQL & php coding”

Who is online

Users browsing this forum: No registered users and 1 guest