PHP mysqli_free_result() Function

Definition

The mysqli_free_result() function frees the memory associated with the result.

Syntax

mysqli_free_result(result);

Parameter

ParameterIs RequiredDescription
resultRequired.Result set identifier returned by mysqli_query(), mysqli_store_result() or mysqli_use_result()

Example

The following code retrieves rows from a resultset, then free the memory associated with the resultset.


<?php/*  w w w  . jav a2  s  .c om*/
$con=mysqli_connect("localhost","my_user","my_password","my_db");
if (mysqli_connect_errno($con)){
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
}

$sql="SELECT name FROM Emp";

if ($result=mysqli_query($con,$sql)){
   while ($row=mysqli_fetch_row($result)){
       printf ("%s (%s)\n",$row[0],$row[1]);
   }   
   mysqli_free_result($result);// clear result set
}

mysqli_close($con);
?>




















Home »
  PHP Tutorial »
    Function reference »




PHP Array Functions
PHP Calendar Functions
PHP Class Functions
PHP Data Type Functions
PHP Date Functions
PHP File Functions
PHP Image Functions
PHP Math Functions
PHP MySQLi Functions
PHP SimpleXML Functions
PHP String Functions
PHP XML Functions
PHP Zip Functions