PHP mysqli_free_result() Function
Definition
The mysqli_free_result() function frees the memory associated with the result.
Syntax
mysqli_free_result(result);
Parameter
Parameter | Is Required | Description |
---|---|---|
result | Required. | 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);
?>