PHP mysql_free_result() function

Definition and Usage

The mysql_free_result() function releases the result memory.

Returns true if successful, and false if unsuccessful.

Syntax

mysql_free_result(data)
Parameters Description
data Required. The result identifier to be released. The result identifier is from mysql_query() The returned results.

Tips and Comments

Note:mysql_free_result() should be called only when considering how much memory will be occupied by a large result set. All associated memory will be automatically released at the end of the script.

Example

<?php
$con = mysql_connect("localhost", "peter", "abc123");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }
$db_selected = mysql_select_db("test_db",$con);
$sql = "SELECT * from Person";
$result = mysql_query($sql,$con);
print_r(mysql_fetch_row($result));
// Free memory
mysql_free_result($result);
$sql = "SELECT * from Customers";
$result = mysql_query($sql,$con);
print_r(mysql_fetch_row($result));
mysql_close($con);
?>